diff --git a/core/modules/file/tests/src/Functional/FileFieldAnonymousSubmissionTest.php b/core/modules/file/tests/src/Functional/FileFieldAnonymousSubmissionTest.php index 0cee386a287..48937fe4ee4 100644 --- a/core/modules/file/tests/src/Functional/FileFieldAnonymousSubmissionTest.php +++ b/core/modules/file/tests/src/Functional/FileFieldAnonymousSubmissionTest.php @@ -93,7 +93,7 @@ class FileFieldAnonymousSubmissionTest extends FileFieldTestBase { $this->assertNotEqual($nid, 0, 'The node ID was extracted from the URL.'); $node = Node::load($nid); $this->assertNotEqual($node, NULL, 'The node was loaded successfully.'); - $this->assertFileExists(File::load($node->field_image->target_id)->getFileUri(), 'The image was uploaded successfully.'); + $this->assertFileExists(File::load($node->field_image->target_id)->getFileUri()); } } @@ -167,7 +167,7 @@ class FileFieldAnonymousSubmissionTest extends FileFieldTestBase { $this->assertNotEqual($nid, 0, 'The node ID was extracted from the URL.'); $node = Node::load($nid); $this->assertNotEqual($node, NULL, 'The node was loaded successfully.'); - $this->assertFileExists(File::load($node->field_image->target_id)->getFileUri(), 'The image was uploaded successfully.'); + $this->assertFileExists(File::load($node->field_image->target_id)->getFileUri()); } } diff --git a/core/modules/file/tests/src/Functional/FileFieldRevisionTest.php b/core/modules/file/tests/src/Functional/FileFieldRevisionTest.php index 39136b2f55e..e812cd8ee4c 100644 --- a/core/modules/file/tests/src/Functional/FileFieldRevisionTest.php +++ b/core/modules/file/tests/src/Functional/FileFieldRevisionTest.php @@ -51,7 +51,7 @@ class FileFieldRevisionTest extends FileFieldTestBase { $node = $node_storage->load($nid); $node_file_r1 = File::load($node->{$field_name}->target_id); $node_vid_r1 = $node->getRevisionId(); - $this->assertFileExists($node_file_r1->getFileUri(), 'New file saved to disk on node creation.'); + $this->assertFileExists($node_file_r1->getFileUri()); $this->assertFileEntryExists($node_file_r1, 'File entry exists in database on node creation.'); $this->assertFileIsPermanent($node_file_r1, 'File is permanent.'); @@ -61,7 +61,7 @@ class FileFieldRevisionTest extends FileFieldTestBase { $node = $node_storage->load($nid); $node_file_r2 = File::load($node->{$field_name}->target_id); $node_vid_r2 = $node->getRevisionId(); - $this->assertFileExists($node_file_r2->getFileUri(), 'Replacement file exists on disk after creating new revision.'); + $this->assertFileExists($node_file_r2->getFileUri()); $this->assertFileEntryExists($node_file_r2, 'Replacement file entry exists in database after creating new revision.'); $this->assertFileIsPermanent($node_file_r2, 'Replacement file is permanent.'); @@ -69,7 +69,7 @@ class FileFieldRevisionTest extends FileFieldTestBase { $node = node_revision_load($node_vid_r1); $current_file = File::load($node->{$field_name}->target_id); $this->assertEqual($node_file_r1->id(), $current_file->id(), 'Original file still in place after replacing file in new revision.'); - $this->assertFileExists($node_file_r1->getFileUri(), 'Original file still in place after replacing file in new revision.'); + $this->assertFileExists($node_file_r1->getFileUri()); $this->assertFileEntryExists($node_file_r1, 'Original file entry still in place after replacing file in new revision'); $this->assertFileIsPermanent($node_file_r1, 'Original file is still permanent.'); @@ -94,7 +94,7 @@ class FileFieldRevisionTest extends FileFieldTestBase { // Delete the second revision and check that the file is kept (since it is // still being used by the third revision). $this->drupalPostForm('node/' . $nid . '/revisions/' . $node_vid_r2 . '/delete', [], t('Delete')); - $this->assertFileExists($node_file_r3->getFileUri(), 'Second file is still available after deleting second revision, since it is being used by the third revision.'); + $this->assertFileExists($node_file_r3->getFileUri()); $this->assertFileEntryExists($node_file_r3, 'Second file entry is still available after deleting second revision, since it is being used by the third revision.'); $this->assertFileIsPermanent($node_file_r3, 'Second file entry is still permanent after deleting second revision, since it is being used by the third revision.'); @@ -107,7 +107,7 @@ class FileFieldRevisionTest extends FileFieldTestBase { // Delete the third revision and check that the file is not deleted yet. $this->drupalPostForm('node/' . $nid . '/revisions/' . $node_vid_r3 . '/delete', [], t('Delete')); - $this->assertFileExists($node_file_r3->getFileUri(), 'Second file is still available after deleting third revision, since it is being used by the user.'); + $this->assertFileExists($node_file_r3->getFileUri()); $this->assertFileEntryExists($node_file_r3, 'Second file entry is still available after deleting third revision, since it is being used by the user.'); $this->assertFileIsPermanent($node_file_r3, 'Second file entry is still permanent after deleting third revision, since it is being used by the user.'); @@ -134,7 +134,7 @@ class FileFieldRevisionTest extends FileFieldTestBase { ->execute(); \Drupal::service('cron')->run(); - $this->assertFileNotExists($node_file_r3->getFileUri(), 'Second file is now deleted after deleting third revision, since it is no longer being used by any other nodes.'); + $this->assertFileNotExists($node_file_r3->getFileUri()); $this->assertFileEntryNotExists($node_file_r3, 'Second file entry is now deleted after deleting third revision, since it is no longer being used by any other nodes.'); // Delete the entire node and check that the original file is deleted. @@ -150,7 +150,7 @@ class FileFieldRevisionTest extends FileFieldTestBase { ->condition('fid', $node_file_r1->id()) ->execute(); \Drupal::service('cron')->run(); - $this->assertFileNotExists($node_file_r1->getFileUri(), 'Original file is deleted after deleting the entire node with two revisions remaining.'); + $this->assertFileNotExists($node_file_r1->getFileUri()); $this->assertFileEntryNotExists($node_file_r1, 'Original file entry is deleted after deleting the entire node with two revisions remaining.'); } diff --git a/core/modules/file/tests/src/Functional/FileFieldValidateTest.php b/core/modules/file/tests/src/Functional/FileFieldValidateTest.php index 334cdf47c03..51698a6257f 100644 --- a/core/modules/file/tests/src/Functional/FileFieldValidateTest.php +++ b/core/modules/file/tests/src/Functional/FileFieldValidateTest.php @@ -46,7 +46,7 @@ class FileFieldValidateTest extends FileFieldTestBase { $node = $node_storage->load($nid); $node_file = File::load($node->{$field_name}->target_id); - $this->assertFileExists($node_file->getFileUri(), 'File exists after uploading to the required field.'); + $this->assertFileExists($node_file->getFileUri()); $this->assertFileEntryExists($node_file, 'File entry exists after uploading to the required field.'); // Try again with a multiple value field. @@ -64,7 +64,7 @@ class FileFieldValidateTest extends FileFieldTestBase { $node_storage->resetCache([$nid]); $node = $node_storage->load($nid); $node_file = File::load($node->{$field_name}->target_id); - $this->assertFileExists($node_file->getFileUri(), 'File exists after uploading to the required multiple value field.'); + $this->assertFileExists($node_file->getFileUri()); $this->assertFileEntryExists($node_file, 'File entry exists after uploading to the required multiple value field.'); } @@ -98,7 +98,7 @@ class FileFieldValidateTest extends FileFieldTestBase { $node_storage->resetCache([$nid]); $node = $node_storage->load($nid); $node_file = File::load($node->{$field_name}->target_id); - $this->assertFileExists($node_file->getFileUri(), new FormattableMarkup('File exists after uploading a file (%filesize) under the max limit (%maxsize).', ['%filesize' => format_size($small_file->getSize()), '%maxsize' => $max_filesize])); + $this->assertFileExists($node_file->getFileUri()); $this->assertFileEntryExists($node_file, new FormattableMarkup('File entry exists after uploading a file (%filesize) under the max limit (%maxsize).', ['%filesize' => format_size($small_file->getSize()), '%maxsize' => $max_filesize])); // Check that uploading the large file fails (1M limit). @@ -115,7 +115,7 @@ class FileFieldValidateTest extends FileFieldTestBase { $node_storage->resetCache([$nid]); $node = $node_storage->load($nid); $node_file = File::load($node->{$field_name}->target_id); - $this->assertFileExists($node_file->getFileUri(), new FormattableMarkup('File exists after uploading a file (%filesize) with no max limit.', ['%filesize' => format_size($large_file->getSize())])); + $this->assertFileExists($node_file->getFileUri()); $this->assertFileEntryExists($node_file, new FormattableMarkup('File entry exists after uploading a file (%filesize) with no max limit.', ['%filesize' => format_size($large_file->getSize())])); } @@ -139,7 +139,7 @@ class FileFieldValidateTest extends FileFieldTestBase { $node_storage->resetCache([$nid]); $node = $node_storage->load($nid); $node_file = File::load($node->{$field_name}->target_id); - $this->assertFileExists($node_file->getFileUri(), 'File exists after uploading a file with no extension checking.'); + $this->assertFileExists($node_file->getFileUri()); $this->assertFileEntryExists($node_file, 'File entry exists after uploading a file with no extension checking.'); // Enable extension checking for text files. @@ -158,7 +158,7 @@ class FileFieldValidateTest extends FileFieldTestBase { $node_storage->resetCache([$nid]); $node = $node_storage->load($nid); $node_file = File::load($node->{$field_name}->target_id); - $this->assertFileExists($node_file->getFileUri(), 'File exists after uploading a file with extension checking.'); + $this->assertFileExists($node_file->getFileUri()); $this->assertFileEntryExists($node_file, 'File entry exists after uploading a file with extension checking.'); } @@ -181,7 +181,7 @@ class FileFieldValidateTest extends FileFieldTestBase { $node_storage->resetCache([$nid]); $node = $node_storage->load($nid); $node_file = File::load($node->{$field_name}->target_id); - $this->assertFileExists($node_file->getFileUri(), 'File exists after uploading a file with no extension checking.'); + $this->assertFileExists($node_file->getFileUri()); $this->assertFileEntryExists($node_file, 'File entry exists after uploading a file with no extension checking.'); // Enable extension checking for text files. diff --git a/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php b/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php index 449c5a40738..fe1c6254091 100644 --- a/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php +++ b/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php @@ -89,7 +89,7 @@ class FileFieldWidgetTest extends FileFieldTestBase { $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $node = $node_storage->loadUnchanged($nid); $node_file = File::load($node->{$field_name}->target_id); - $this->assertFileExists($node_file->getFileUri(), 'New file saved to disk on node creation.'); + $this->assertFileExists($node_file->getFileUri()); // Ensure the file can be downloaded. $this->drupalGet($node_file->createFileUrl()); @@ -263,7 +263,7 @@ class FileFieldWidgetTest extends FileFieldTestBase { $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $node = $node_storage->loadUnchanged($nid); $node_file = File::load($node->{$field_name}->target_id); - $this->assertFileExists($node_file->getFileUri(), 'New file saved to disk on node creation.'); + $this->assertFileExists($node_file->getFileUri()); // Ensure the private file is available to the user who uploaded it. $this->drupalGet($node_file->createFileUrl()); @@ -330,7 +330,7 @@ class FileFieldWidgetTest extends FileFieldTestBase { $comment = Comment::load($cid); $comment_file = $comment->{'field_' . $name}->entity; - $this->assertFileExists($comment_file->getFileUri(), 'New file saved to disk on node creation.'); + $this->assertFileExists($comment_file->getFileUri()); // Test authenticated file download. $url = $comment_file->createFileUrl(); $this->assertNotEqual($url, NULL, 'Confirmed that the URL is valid'); @@ -507,7 +507,7 @@ class FileFieldWidgetTest extends FileFieldTestBase { /** @var \Drupal\file\FileInterface $node_file */ $node_file = File::load($node->{$field_name}->target_id); - $this->assertFileExists($node_file->getFileUri(), 'A file was saved to disk on node creation'); + $this->assertFileExists($node_file->getFileUri()); $this->assertEqual($attacker_user->id(), $node_file->getOwnerId(), 'New file belongs to the attacker.'); // Ensure the file can be downloaded. diff --git a/core/modules/migrate/tests/src/Kernel/process/DownloadTest.php b/core/modules/migrate/tests/src/Kernel/process/DownloadTest.php index 9432c707edd..94c4a93e95b 100644 --- a/core/modules/migrate/tests/src/Kernel/process/DownloadTest.php +++ b/core/modules/migrate/tests/src/Kernel/process/DownloadTest.php @@ -40,7 +40,7 @@ class DownloadTest extends FileTestBase { // Test destructive download. $actual_destination = $this->doTransform($destination_uri); $this->assertSame($destination_uri, $actual_destination, 'Import returned a destination that was not renamed'); - $this->assertFileNotExists('public://existing_file_0.txt', 'Import did not rename the file'); + $this->assertFileNotExists('public://existing_file_0.txt'); } /** @@ -53,7 +53,7 @@ class DownloadTest extends FileTestBase { // Test non-destructive download. $actual_destination = $this->doTransform($destination_uri, ['file_exists' => 'rename']); $this->assertSame('public://another_existing_file_0.txt', $actual_destination, 'Import returned a renamed destination'); - $this->assertFileExists($actual_destination, 'Downloaded file was created'); + $this->assertFileExists($actual_destination); } /** diff --git a/core/modules/migrate/tests/src/Kernel/process/FileCopyTest.php b/core/modules/migrate/tests/src/Kernel/process/FileCopyTest.php index 22ac8f72a9f..4575db0d82c 100644 --- a/core/modules/migrate/tests/src/Kernel/process/FileCopyTest.php +++ b/core/modules/migrate/tests/src/Kernel/process/FileCopyTest.php @@ -67,10 +67,9 @@ class FileCopyTest extends FileTestBase { foreach ($data_sets as $data) { list($source_path, $destination_path) = $data; $actual_destination = $this->doTransform($source_path, $destination_path); - $message = sprintf('File %s exists', $destination_path); - $this->assertFileExists($destination_path, $message); + $this->assertFileExists($destination_path); // Make sure we didn't accidentally do a move. - $this->assertFileExists($source_path, $message); + $this->assertFileExists($source_path); $this->assertSame($actual_destination, $destination_path, 'The import returned the copied filename.'); } } @@ -152,10 +151,8 @@ class FileCopyTest extends FileTestBase { foreach ($data_sets as $data) { list($source_path, $destination_path) = $data; $actual_destination = $this->doTransform($source_path, $destination_path, ['move' => TRUE]); - $message = sprintf('File %s exists', $destination_path); - $this->assertFileExists($destination_path, $message); - $message = sprintf('File %s does not exist', $source_path); - $this->assertFileNotExists($source_path, $message); + $this->assertFileExists($destination_path); + $this->assertFileNotExists($source_path); $this->assertSame($actual_destination, $destination_path, 'The importer returned the moved filename.'); } } @@ -205,7 +202,7 @@ class FileCopyTest extends FileTestBase { $destination = $this->createUri('foo.txt', NULL, 'public'); $expected_destination = 'public://foo_0.txt'; $actual_destination = $this->doTransform($source, $destination, ['file_exists' => 'rename']); - $this->assertFileExists($expected_destination, 'File was renamed on import'); + $this->assertFileExists($expected_destination); $this->assertSame($actual_destination, $expected_destination, 'The importer returned the renamed filename.'); } diff --git a/core/modules/user/tests/src/Functional/UserPictureTest.php b/core/modules/user/tests/src/Functional/UserPictureTest.php index dff036b5baf..16fdfd41b24 100644 --- a/core/modules/user/tests/src/Functional/UserPictureTest.php +++ b/core/modules/user/tests/src/Functional/UserPictureTest.php @@ -94,7 +94,7 @@ class UserPictureTest extends BrowserTestBase { $this->assertNull(File::load($file->id()), 'File was removed from the database.'); // Clear out PHP's file stat cache so we see the current value. clearstatcache(TRUE, $file->getFileUri()); - $this->assertFileNotExists($file->getFileUri(), 'File was removed from the file system.'); + $this->assertFileNotExists($file->getFileUri()); } /** diff --git a/core/tests/Drupal/KernelTests/Core/Theme/Stable9LibraryOverrideTest.php b/core/tests/Drupal/KernelTests/Core/Theme/Stable9LibraryOverrideTest.php index 7ace13dd81f..073e0f41dcb 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/Stable9LibraryOverrideTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/Stable9LibraryOverrideTest.php @@ -125,8 +125,8 @@ class Stable9LibraryOverrideTest extends KernelTestBase { $assert_path = str_replace("core/modules/$extension/", '', $clean_path); $this->assertEqual($expected_path, $stable_path, "$assert_path from the $extension/$library_name library is overridden in Stable 9."); - $this->assertFileExists("{$this->root}/$clean_path", "$clean_path exists."); - $this->assertFileExists("{$this->root}/$stable_path", "$stable_path exists."); + $this->assertFileExists("{$this->root}/$clean_path"); + $this->assertFileExists("{$this->root}/$stable_path"); } } }