diff --git a/core/modules/media_library/tests/src/FunctionalJavascript/UploadFail.php b/core/modules/media_library/tests/src/FunctionalJavascript/UploadFail.php index 4525c4ca8a..a2f723fa16 100644 --- a/core/modules/media_library/tests/src/FunctionalJavascript/UploadFail.php +++ b/core/modules/media_library/tests/src/FunctionalJavascript/UploadFail.php @@ -8,6 +8,7 @@ use Drupal\FunctionalJavascriptTests\WebDriverTestBase; use Drupal\media\Entity\Media; use Drupal\Tests\TestFileCreationTrait; +use PHPUnit\Framework\AssertionFailedError; /** * Checks if uploads fail after several attempts. @@ -24,6 +25,7 @@ class UploadFail extends WebDriverTestBase { protected static $modules = [ 'media_library_test', 'node', + 'dblog', ]; /** @@ -75,10 +77,24 @@ public function testManyConsecutiveUploads() { $media_count = $database->select('file_managed')->countQuery()->execute()->fetchField(); $this->assertEquals($count, $media_count); $page->attachFileToField('Add files', $new_filepath); - $this->assertTrue($page->waitFor(10, function () use ($database, $count) { + $result = $page->waitFor(10, function () use ($database, $count) { $media_count = $database->select('file_managed')->countQuery()->execute()->fetchField(); return ($count + 1) === intval($media_count); - }), "The file_managed table wasn't updated iteration $count"); + }); + if (!$result) { + $logs = $database + ->select('watchdog', 'w') + ->fields('w', ['message', 'variables']) + ->condition('type', 'file') + ->orderBy('wid', 'DESC') + ->execute() + ->fetchAll(); + $output = ''; + foreach ($logs as $log) { + $output .= 'message: ' . $log->message . ', variables: . '$log->variables; + } + throw new AssertionFailedError($output); + } $this->waitForText('Alternative text', 10000, "Alternative text field not found on iteration $count"); $field = $page->findField('Alternative text'); $this->assertTrue(!empty($field), "Alt text label found but not the field on iteration $count");