diff --git a/core/modules/file/lib/Drupal/file/Tests/CopyTest.php b/core/modules/file/lib/Drupal/file/Tests/CopyTest.php index 7f20c9f..4a6b1e5 100644 --- a/core/modules/file/lib/Drupal/file/Tests/CopyTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/CopyTest.php @@ -32,16 +32,16 @@ class CopyTest extends FileManagedTestBase { $result = file_copy(clone $source, $desired_uri, FILE_EXISTS_ERROR); // Check the return status and that the contents changed. - $this->assertTrue($result, t('File copied successfully.')); - $this->assertEqual($contents, file_get_contents($result->uri), t('Contents of file were copied correctly.')); + $this->assertTrue($result, 'File copied successfully.'); + $this->assertEqual($contents, file_get_contents($result->uri), 'Contents of file were copied correctly.'); // Check that the correct hooks were called. $this->assertFileHooksCalled(array('copy', 'insert')); $this->assertDifferentFile($source, $result); - $this->assertEqual($result->uri, $desired_uri, t('The copied file entity has the desired filepath.')); - $this->assertTrue(file_exists($source->uri), t('The original file still exists.')); - $this->assertTrue(file_exists($result->uri), t('The copied file exists.')); + $this->assertEqual($result->uri, $desired_uri, 'The copied file entity has the desired filepath.'); + $this->assertTrue(file_exists($source->uri), 'The original file still exists.'); + $this->assertTrue(file_exists($result->uri), 'The copied file exists.'); // Reload the file from the database and check that the changes were // actually saved. @@ -63,9 +63,9 @@ class CopyTest extends FileManagedTestBase { $result = file_copy(clone $source, $target->uri, FILE_EXISTS_RENAME); // Check the return status and that the contents changed. - $this->assertTrue($result, t('File copied successfully.')); - $this->assertEqual($contents, file_get_contents($result->uri), t('Contents of file were copied correctly.')); - $this->assertNotEqual($result->uri, $source->uri, t('Returned file path has changed from the original.')); + $this->assertTrue($result, 'File copied successfully.'); + $this->assertEqual($contents, file_get_contents($result->uri), 'Contents of file were copied correctly.'); + $this->assertNotEqual($result->uri, $source->uri, 'Returned file path has changed from the original.'); // Check that the correct hooks were called. $this->assertFileHooksCalled(array('copy', 'insert')); @@ -103,8 +103,8 @@ class CopyTest extends FileManagedTestBase { $result = file_copy(clone $source, $target->uri, FILE_EXISTS_REPLACE); // Check the return status and that the contents changed. - $this->assertTrue($result, t('File copied successfully.')); - $this->assertEqual($contents, file_get_contents($result->uri), t('Contents of file were overwritten.')); + $this->assertTrue($result, 'File copied successfully.'); + $this->assertEqual($contents, file_get_contents($result->uri), 'Contents of file were overwritten.'); $this->assertDifferentFile($source, $result); // Check that the correct hooks were called. @@ -141,8 +141,8 @@ class CopyTest extends FileManagedTestBase { $result = file_copy(clone $source, $target->uri, FILE_EXISTS_ERROR); // Check the return status and that the contents were not changed. - $this->assertFalse($result, t('File copy failed.')); - $this->assertEqual($contents, file_get_contents($target->uri), t('Contents of file were not altered.')); + $this->assertFalse($result, 'File copy failed.'); + $this->assertEqual($contents, file_get_contents($target->uri), 'Contents of file were not altered.'); // Check that the correct hooks were called. $this->assertFileHooksCalled(array()); diff --git a/core/modules/file/lib/Drupal/file/Tests/DeleteTest.php b/core/modules/file/lib/Drupal/file/Tests/DeleteTest.php index be2f8a4..e387b8c 100644 --- a/core/modules/file/lib/Drupal/file/Tests/DeleteTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/DeleteTest.php @@ -26,11 +26,11 @@ class DeleteTest extends FileManagedTestBase { $file = $this->createFile(); // Check that deletion removes the file and database record. - $this->assertTrue(is_file($file->uri), t('File exists.')); + $this->assertTrue(is_file($file->uri), 'File exists.'); $file->delete(); $this->assertFileHooksCalled(array('delete', 'load')); - $this->assertFalse(file_exists($file->uri), t('Test file has actually been deleted.')); - $this->assertFalse(file_load($file->fid), t('File was removed from the database.')); + $this->assertFalse(file_exists($file->uri), 'Test file has actually been deleted.'); + $this->assertFalse(file_load($file->fid), 'File was removed from the database.'); } /** @@ -43,9 +43,9 @@ class DeleteTest extends FileManagedTestBase { file_usage_delete($file, 'testing', 'test', 1); $usage = file_usage_list($file); - $this->assertEqual($usage['testing']['test'], array(1 => 1), t('Test file is still in use.')); - $this->assertTrue(file_exists($file->uri), t('File still exists on the disk.')); - $this->assertTrue(file_load($file->fid), t('File still exists in the database.')); + $this->assertEqual($usage['testing']['test'], array(1 => 1), 'Test file is still in use.'); + $this->assertTrue(file_exists($file->uri), 'File still exists on the disk.'); + $this->assertTrue(file_load($file->fid), 'File still exists in the database.'); // Clear out the call to hook_file_load(). file_test_reset(); @@ -53,7 +53,7 @@ class DeleteTest extends FileManagedTestBase { file_usage_delete($file, 'testing', 'test', 1); $usage = file_usage_list($file); $this->assertFileHooksCalled(array('load', 'update')); - $this->assertTrue(empty($usage), t('File usage data was removed.')); + $this->assertTrue(empty($usage), 'File usage data was removed.'); $this->assertTrue(file_exists($file->uri), 'File still exists on the disk.'); $file = file_load($file->fid); $this->assertTrue($file, 'File still exists in the database.'); @@ -72,7 +72,7 @@ class DeleteTest extends FileManagedTestBase { // system_cron() loads $this->assertFileHooksCalled(array('load', 'delete')); - $this->assertFalse(file_exists($file->uri), t('File has been deleted after its last usage was removed.')); - $this->assertFalse(file_load($file->fid), t('File was removed from the database.')); + $this->assertFalse(file_exists($file->uri), 'File has been deleted after its last usage was removed.'); + $this->assertFalse(file_load($file->fid), 'File was removed from the database.'); } } diff --git a/core/modules/file/lib/Drupal/file/Tests/DownloadTest.php b/core/modules/file/lib/Drupal/file/Tests/DownloadTest.php index 0763507..8e09e80 100644 --- a/core/modules/file/lib/Drupal/file/Tests/DownloadTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/DownloadTest.php @@ -35,17 +35,17 @@ class DownloadTest extends FileManagedTestBase { // URLs can't contain characters outside the ASCII set so $filename has to be // encoded. $filename = $GLOBALS['base_url'] . '/' . file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath() . '/' . rawurlencode($file->filename); - $this->assertEqual($filename, $url, t('Correctly generated a URL for a created file.')); + $this->assertEqual($filename, $url, 'Correctly generated a URL for a created file.'); $this->drupalHead($url); - $this->assertResponse(200, t('Confirmed that the generated URL is correct by downloading the created file.')); + $this->assertResponse(200, 'Confirmed that the generated URL is correct by downloading the created file.'); // Test generating an URL to a shipped file (i.e. a file that is part of // Drupal core, a module or a theme, for example a JavaScript file). $filepath = 'core/misc/jquery.js'; $url = file_create_url($filepath); - $this->assertEqual($GLOBALS['base_url'] . '/' . $filepath, $url, t('Correctly generated a URL for a shipped file.')); + $this->assertEqual($GLOBALS['base_url'] . '/' . $filepath, $url, 'Correctly generated a URL for a shipped file.'); $this->drupalHead($url); - $this->assertResponse(200, t('Confirmed that the generated URL is correct by downloading the shipped file.')); + $this->assertResponse(200, 'Confirmed that the generated URL is correct by downloading the shipped file.'); } /** @@ -63,21 +63,21 @@ class DownloadTest extends FileManagedTestBase { file_test_set_return('download', array('x-foo' => 'Bar')); $this->drupalGet($url); $headers = $this->drupalGetHeaders(); - $this->assertEqual($headers['x-foo'], 'Bar', t('Found header set by file_test module on private download.')); - $this->assertResponse(200, t('Correctly allowed access to a file when file_test provides headers.')); + $this->assertEqual($headers['x-foo'], 'Bar', 'Found header set by file_test module on private download.'); + $this->assertResponse(200, 'Correctly allowed access to a file when file_test provides headers.'); // Test that the file transfered correctly. - $this->assertEqual($contents, $this->content, t('Contents of the file are correct.')); + $this->assertEqual($contents, $this->content, 'Contents of the file are correct.'); // Deny access to all downloads via a -1 header. file_test_set_return('download', -1); $this->drupalHead($url); - $this->assertResponse(403, t('Correctly denied access to a file when file_test sets the header to -1.')); + $this->assertResponse(403, 'Correctly denied access to a file when file_test sets the header to -1.'); // Try non-existent file. $url = file_create_url('private://' . $this->randomName()); $this->drupalHead($url); - $this->assertResponse(404, t('Correctly returned 404 response for a non-existent file.')); + $this->assertResponse(404, 'Correctly returned 404 response for a non-existent file.'); } /** @@ -134,7 +134,7 @@ class DownloadTest extends FileManagedTestBase { $file = $this->createFile($filepath, NULL, $scheme); $url = file_create_url($file->uri); - $this->assertEqual($url, $expected_url, t('Generated URL matches expected URL.')); + $this->assertEqual($url, $expected_url, 'Generated URL matches expected URL.'); if ($scheme == 'private') { // Tell the implementation of hook_file_download() in file_test.module @@ -144,7 +144,7 @@ class DownloadTest extends FileManagedTestBase { $this->drupalGet($url); if ($this->assertResponse(200) == 'pass') { - $this->assertRaw(file_get_contents($file->uri), t('Contents of the file are correct.')); + $this->assertRaw(file_get_contents($file->uri), 'Contents of the file are correct.'); } $file->delete(); diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php index 9d7dd30..7aacf93 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php @@ -60,13 +60,13 @@ class FileFieldDisplayTest extends FileFieldTestBase { $node = node_load($nid, TRUE); $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); $default_output = theme('file_link', array('file' => $node_file)); - $this->assertRaw($default_output, t('Default formatter displaying correctly on full node view.')); + $this->assertRaw($default_output, 'Default formatter displaying correctly on full node view.'); // Turn the "display" option off and check that the file is no longer displayed. $edit = array($field_name . '[' . LANGUAGE_NOT_SPECIFIED . '][0][display]' => FALSE); $this->drupalPost('node/' . $nid . '/edit', $edit, t('Save')); - $this->assertNoRaw($default_output, t('Field is hidden when "display" option is unchecked.')); + $this->assertNoRaw($default_output, 'Field is hidden when "display" option is unchecked.'); } } diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php index 480f411..d502299 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php @@ -49,25 +49,25 @@ class FileFieldRevisionTest extends FileFieldTestBase { $node = node_load($nid, TRUE); $node_file_r1 = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); $node_vid_r1 = $node->vid; - $this->assertFileExists($node_file_r1, t('New file saved to disk on node creation.')); - $this->assertFileEntryExists($node_file_r1, t('File entry exists in database on node creation.')); - $this->assertFileIsPermanent($node_file_r1, t('File is permanent.')); + $this->assertFileExists($node_file_r1, 'New file saved to disk on node creation.'); + $this->assertFileEntryExists($node_file_r1, 'File entry exists in database on node creation.'); + $this->assertFileIsPermanent($node_file_r1, 'File is permanent.'); // Upload another file to the same node in a new revision. $this->replaceNodeFile($test_file, $field_name, $nid); $node = node_load($nid, TRUE); $node_file_r2 = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); $node_vid_r2 = $node->vid; - $this->assertFileExists($node_file_r2, t('Replacement file exists on disk after creating new revision.')); - $this->assertFileEntryExists($node_file_r2, t('Replacement file entry exists in database after creating new revision.')); - $this->assertFileIsPermanent($node_file_r2, t('Replacement file is permanent.')); + $this->assertFileExists($node_file_r2, 'Replacement file exists on disk after creating new revision.'); + $this->assertFileEntryExists($node_file_r2, 'Replacement file entry exists in database after creating new revision.'); + $this->assertFileIsPermanent($node_file_r2, 'Replacement file is permanent.'); // Check that the original file is still in place on the first revision. $node = node_revision_load($node_vid_r1); - $this->assertEqual($node_file_r1, file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']), t('Original file still in place after replacing file in new revision.')); - $this->assertFileExists($node_file_r1, t('Original file still in place after replacing file in new revision.')); - $this->assertFileEntryExists($node_file_r1, t('Original file entry still in place after replacing file in new revision')); - $this->assertFileIsPermanent($node_file_r1, t('Original file is still permanent.')); + $this->assertEqual($node_file_r1, file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']), 'Original file still in place after replacing file in new revision.'); + $this->assertFileExists($node_file_r1, 'Original file still in place after replacing file in new revision.'); + $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.'); // Save a new version of the node without any changes. // Check that the file is still the same as the previous revision. @@ -75,23 +75,23 @@ class FileFieldRevisionTest extends FileFieldTestBase { $node = node_load($nid, TRUE); $node_file_r3 = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); $node_vid_r3 = $node->vid; - $this->assertEqual($node_file_r2, $node_file_r3, t('Previous revision file still in place after creating a new revision without a new file.')); - $this->assertFileIsPermanent($node_file_r3, t('New revision file is permanent.')); + $this->assertEqual($node_file_r2, $node_file_r3, 'Previous revision file still in place after creating a new revision without a new file.'); + $this->assertFileIsPermanent($node_file_r3, 'New revision file is permanent.'); // Revert to the first revision and check that the original file is active. $this->drupalPost('node/' . $nid . '/revisions/' . $node_vid_r1 . '/revert', array(), t('Revert')); $node = node_load($nid, TRUE); $node_file_r4 = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); $node_vid_r4 = $node->vid; - $this->assertEqual($node_file_r1, $node_file_r4, t('Original revision file still in place after reverting to the original revision.')); - $this->assertFileIsPermanent($node_file_r4, t('Original revision file still permanent after reverting to the original revision.')); + $this->assertEqual($node_file_r1, $node_file_r4, 'Original revision file still in place after reverting to the original revision.'); + $this->assertFileIsPermanent($node_file_r4, 'Original revision file still permanent after reverting to the original revision.'); // Delete the second revision and check that the file is kept (since it is // still being used by the third revision). $this->drupalPost('node/' . $nid . '/revisions/' . $node_vid_r2 . '/delete', array(), t('Delete')); - $this->assertFileExists($node_file_r3, t('Second file is still available after deleting second revision, since it is being used by the third revision.')); - $this->assertFileEntryExists($node_file_r3, t('Second file entry is still available after deleting second revision, since it is being used by the third revision.')); - $this->assertFileIsPermanent($node_file_r3, t('Second file entry is still permanent after deleting second revision, since it is being used by the third revision.')); + $this->assertFileExists($node_file_r3, 'Second file is still available after deleting second revision, since it is being used by the third revision.'); + $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.'); // Attach the second file to a user. $user = $this->drupalCreateUser(); @@ -102,9 +102,9 @@ class FileFieldRevisionTest extends FileFieldTestBase { // Delete the third revision and check that the file is not deleted yet. $this->drupalPost('node/' . $nid . '/revisions/' . $node_vid_r3 . '/delete', array(), t('Delete')); - $this->assertFileExists($node_file_r3, t('Second file is still available after deleting third revision, since it is being used by the user.')); - $this->assertFileEntryExists($node_file_r3, t('Second file entry is still available after deleting third revision, since it is being used by the user.')); - $this->assertFileIsPermanent($node_file_r3, t('Second file entry is still permanent after deleting third revision, since it is being used by the user.')); + $this->assertFileExists($node_file_r3, 'Second file is still available after deleting third revision, since it is being used by the user.'); + $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.'); // Delete the user and check that the file is also deleted. user_delete($user->uid); @@ -126,8 +126,8 @@ class FileFieldRevisionTest extends FileFieldTestBase { ->execute(); drupal_cron_run(); - $this->assertFileNotExists($node_file_r3, t('Second file is now deleted after deleting third revision, since it is no longer being used by any other nodes.')); - $this->assertFileEntryNotExists($node_file_r3, t('Second file entry is now deleted after deleting third revision, since it is no longer being used by any other nodes.')); + $this->assertFileNotExists($node_file_r3, 'Second file is now deleted after deleting third revision, since it is no longer being used by any other nodes.'); + $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. $this->drupalPost('node/' . $nid . '/delete', array(), t('Delete')); @@ -140,7 +140,7 @@ class FileFieldRevisionTest extends FileFieldTestBase { ->condition('fid', $node_file_r1->fid) ->execute(); drupal_cron_run(); - $this->assertFileNotExists($node_file_r1, t('Original file is deleted after deleting the entire node with two revisions remaining.')); - $this->assertFileEntryNotExists($node_file_r1, t('Original file entry is deleted after deleting the entire node with two revisions remaining.')); + $this->assertFileNotExists($node_file_r1, 'Original file is deleted after deleting the entire node with two revisions remaining.'); + $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/lib/Drupal/file/Tests/FileFieldTestBase.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php index e291bec..1255c2a 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php @@ -144,7 +144,7 @@ abstract class FileFieldTestBase extends WebTestBase { // Save at least one revision to better simulate a real site. $this->drupalCreateNode(get_object_vars($node)); $node = node_load($nid, TRUE); - $this->assertNotEqual($nid, $node->vid, t('Node revision exists.')); + $this->assertNotEqual($nid, $node->vid, 'Node revision exists.'); } // Attach a file to the node. diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php index 050931b..ee00a3f 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php @@ -38,7 +38,7 @@ class FileFieldValidateTest extends FileFieldTestBase { $langcode = LANGUAGE_NOT_SPECIFIED; $edit = array("title" => $this->randomName()); $this->drupalPost('node/add/' . $type_name, $edit, t('Save')); - $this->assertRaw(t('!title field is required.', array('!title' => $instance['label'])), t('Node save failed when required file field was empty.')); + $this->assertRaw(t('!title field is required.', array('!title' => $instance['label'])), 'Node save failed when required file field was empty.'); // Create a new node with the uploaded file. $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); @@ -47,8 +47,8 @@ class FileFieldValidateTest extends FileFieldTestBase { $node = node_load($nid, TRUE); $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); - $this->assertFileExists($node_file, t('File exists after uploading to the required field.')); - $this->assertFileEntryExists($node_file, t('File entry exists after uploading to the required field.')); + $this->assertFileExists($node_file, 'File exists after uploading to the required field.'); + $this->assertFileEntryExists($node_file, 'File entry exists after uploading to the required field.'); // Try again with a multiple value field. field_delete_field($field_name); @@ -57,14 +57,14 @@ class FileFieldValidateTest extends FileFieldTestBase { // Try to post a new node without uploading a file in the multivalue field. $edit = array('title' => $this->randomName()); $this->drupalPost('node/add/' . $type_name, $edit, t('Save')); - $this->assertRaw(t('!title field is required.', array('!title' => $instance['label'])), t('Node save failed when required multiple value file field was empty.')); + $this->assertRaw(t('!title field is required.', array('!title' => $instance['label'])), 'Node save failed when required multiple value file field was empty.'); // Create a new node with the uploaded file into the multivalue field. $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $node = node_load($nid, TRUE); $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); - $this->assertFileExists($node_file, t('File exists after uploading to the required multiple value field.')); - $this->assertFileEntryExists($node_file, t('File entry exists after uploading to the required multipel value field.')); + $this->assertFileExists($node_file, 'File exists after uploading to the required multiple value field.'); + $this->assertFileEntryExists($node_file, 'File entry exists after uploading to the required multipel value field.'); // Remove our file field. field_delete_field($field_name); @@ -142,8 +142,8 @@ class FileFieldValidateTest extends FileFieldTestBase { $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $node = node_load($nid, TRUE); $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); - $this->assertFileExists($node_file, t('File exists after uploading a file with no extension checking.')); - $this->assertFileEntryExists($node_file, t('File entry exists after uploading a file with no extension checking.')); + $this->assertFileExists($node_file, 'File exists after uploading a file with no extension checking.'); + $this->assertFileEntryExists($node_file, 'File entry exists after uploading a file with no extension checking.'); // Enable extension checking for text files. $this->updateFileField($field_name, $type_name, array('file_extensions' => 'txt')); @@ -151,7 +151,7 @@ class FileFieldValidateTest extends FileFieldTestBase { // Check that the file with the wrong extension cannot be uploaded. $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $error_message = t('Only files with the following extensions are allowed: %files-allowed.', array('%files-allowed' => 'txt')); - $this->assertRaw($error_message, t('Node save failed when file uploaded with the wrong extension.')); + $this->assertRaw($error_message, 'Node save failed when file uploaded with the wrong extension.'); // Enable extension checking for text and image files. $this->updateFileField($field_name, $type_name, array('file_extensions' => "txt $test_file_extension")); @@ -160,8 +160,8 @@ class FileFieldValidateTest extends FileFieldTestBase { $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $node = node_load($nid, TRUE); $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); - $this->assertFileExists($node_file, t('File exists after uploading a file with extension checking.')); - $this->assertFileEntryExists($node_file, t('File entry exists after uploading a file with extension checking.')); + $this->assertFileExists($node_file, 'File exists after uploading a file with extension checking.'); + $this->assertFileEntryExists($node_file, 'File entry exists after uploading a file with extension checking.'); // Remove our file field. field_delete_field($field_name); diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php index 0bb8866..85fbc83 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php @@ -43,16 +43,16 @@ class FileFieldWidgetTest extends FileFieldTestBase { $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $node = node_load($nid, TRUE); $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); - $this->assertFileExists($node_file, t('New file saved to disk on node creation.')); + $this->assertFileExists($node_file, 'New file saved to disk on node creation.'); // Ensure the file can be downloaded. $this->drupalGet(file_create_url($node_file->uri)); - $this->assertResponse(200, t('Confirmed that the generated URL is correct by downloading the shipped file.')); + $this->assertResponse(200, 'Confirmed that the generated URL is correct by downloading the shipped file.'); // Ensure the edit page has a remove button instead of an upload button. $this->drupalGet("node/$nid/edit"); - $this->assertNoFieldByXPath('//input[@type="submit"]', t('Upload'), t('Node with file does not display the "Upload" button.')); - $this->assertFieldByXpath('//input[@type="submit"]', t('Remove'), t('Node with file displays the "Remove" button.')); + $this->assertNoFieldByXPath('//input[@type="submit"]', t('Upload'), 'Node with file does not display the "Upload" button.'); + $this->assertFieldByXpath('//input[@type="submit"]', t('Remove'), 'Node with file displays the "Remove" button.'); // "Click" the remove button (emulating either a nojs or js submission). switch ($type) { @@ -66,8 +66,8 @@ class FileFieldWidgetTest extends FileFieldTestBase { } // Ensure the page now has an upload button instead of a remove button. - $this->assertNoFieldByXPath('//input[@type="submit"]', t('Remove'), t('After clicking the "Remove" button, it is no longer displayed.')); - $this->assertFieldByXpath('//input[@type="submit"]', t('Upload'), t('After clicking the "Remove" button, the "Upload" button is displayed.')); + $this->assertNoFieldByXPath('//input[@type="submit"]', t('Remove'), 'After clicking the "Remove" button, it is no longer displayed.'); + $this->assertFieldByXpath('//input[@type="submit"]', t('Upload'), 'After clicking the "Remove" button, the "Upload" button is displayed.'); // Test label has correct 'for' attribute. $label = $this->xpath("//label[@for='edit-" . drupal_clean_css_identifier($field_name) . "-" . LANGUAGE_NOT_SPECIFIED . "-0-upload']"); $this->assertTrue(isset($label[0]), 'Label for upload found.'); @@ -75,7 +75,7 @@ class FileFieldWidgetTest extends FileFieldTestBase { // Save the node and ensure it does not have the file. $this->drupalPost(NULL, array(), t('Save')); $node = node_load($nid, TRUE); - $this->assertTrue(empty($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']), t('File was successfully removed from the node.')); + $this->assertTrue(empty($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']), 'File was successfully removed from the node.'); } } @@ -119,7 +119,7 @@ class FileFieldWidgetTest extends FileFieldTestBase { $this->drupalPost(NULL, $edit, t('Upload')); } } - $this->assertNoFieldByXpath('//input[@type="submit"]', t('Upload'), t('After uploading 3 files for each field, the "Upload" button is no longer displayed.')); + $this->assertNoFieldByXpath('//input[@type="submit"]', t('Upload'), 'After uploading 3 files for each field, the "Upload" button is no longer displayed.'); $num_expected_remove_buttons = 6; @@ -196,7 +196,7 @@ class FileFieldWidgetTest extends FileFieldTestBase { preg_match('/node\/([0-9]+)/', $this->getUrl(), $matches); $nid = $matches[1]; $node = node_load($nid, TRUE); - $this->assertTrue(empty($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']), t('Node was successfully saved without any files.')); + $this->assertTrue(empty($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']), 'Node was successfully saved without any files.'); } } @@ -222,21 +222,21 @@ class FileFieldWidgetTest extends FileFieldTestBase { $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $node = node_load($nid, TRUE); $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); - $this->assertFileExists($node_file, t('New file saved to disk on node creation.')); + $this->assertFileExists($node_file, 'New file saved to disk on node creation.'); // Ensure the private file is available to the user who uploaded it. $this->drupalGet(file_create_url($node_file->uri)); - $this->assertResponse(200, t('Confirmed that the generated URL is correct by downloading the shipped file.')); + $this->assertResponse(200, 'Confirmed that the generated URL is correct by downloading the shipped file.'); // Ensure we can't change 'uri_scheme' field settings while there are some // entities with uploaded files. $this->drupalGet("admin/structure/types/manage/$type_name/fields/$field_name"); - $this->assertFieldByXpath('//input[@id="edit-field-settings-uri-scheme-public" and @disabled="disabled"]', 'public', t('Upload destination setting disabled.')); + $this->assertFieldByXpath('//input[@id="edit-field-settings-uri-scheme-public" and @disabled="disabled"]', 'public', 'Upload destination setting disabled.'); // Delete node and confirm that setting could be changed. node_delete($nid); $this->drupalGet("admin/structure/types/manage/$type_name/fields/$field_name"); - $this->assertFieldByXpath('//input[@id="edit-field-settings-uri-scheme-public" and not(@disabled)]', 'public', t('Upload destination setting enabled.')); + $this->assertFieldByXpath('//input[@id="edit-field-settings-uri-scheme-public" and not(@disabled)]', 'public', 'Upload destination setting enabled.'); } /** @@ -288,17 +288,17 @@ class FileFieldWidgetTest extends FileFieldTestBase { $comment = comment_load($cid); $comment_file = file_load($comment->{'field_' . $name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); - $this->assertFileExists($comment_file, t('New file saved to disk on node creation.')); + $this->assertFileExists($comment_file, 'New file saved to disk on node creation.'); // Test authenticated file download. $url = file_create_url($comment_file->uri); - $this->assertNotEqual($url, NULL, t('Confirmed that the URL is valid')); + $this->assertNotEqual($url, NULL, 'Confirmed that the URL is valid'); $this->drupalGet(file_create_url($comment_file->uri)); - $this->assertResponse(200, t('Confirmed that the generated URL is correct by downloading the shipped file.')); + $this->assertResponse(200, 'Confirmed that the generated URL is correct by downloading the shipped file.'); // Test anonymous file download. $this->drupalLogout(); $this->drupalGet(file_create_url($comment_file->uri)); - $this->assertResponse(403, t('Confirmed that access is denied for the file without the needed permission.')); + $this->assertResponse(403, 'Confirmed that access is denied for the file without the needed permission.'); // Unpublishes node. $this->drupalLogin($this->admin_user); @@ -310,7 +310,7 @@ class FileFieldWidgetTest extends FileFieldTestBase { // Ensures normal user can no longer download the file. $this->drupalLogin($user); $this->drupalGet(file_create_url($comment_file->uri)); - $this->assertResponse(403, t('Confirmed that access is denied for the file without the needed permission.')); + $this->assertResponse(403, 'Confirmed that access is denied for the file without the needed permission.'); } } diff --git a/core/modules/file/lib/Drupal/file/Tests/FileManagedFileElementTest.php b/core/modules/file/lib/Drupal/file/Tests/FileManagedFileElementTest.php index 9865314..cd234f0 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileManagedFileElementTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileManagedFileElementTest.php @@ -40,19 +40,19 @@ class FileManagedFileElementTest extends FileFieldTestBase { // Submit without a file. $this->drupalPost($path, array(), t('Save')); - $this->assertRaw(t('The file id is %fid.', array('%fid' => 0)), t('Submitted without a file.')); + $this->assertRaw(t('The file id is %fid.', array('%fid' => 0)), 'Submitted without a file.'); // Submit a new file, without using the Upload button. $last_fid_prior = $this->getLastFileId(); $edit = array('files[' . $input_base_name . ']' => drupal_realpath($test_file->uri)); $this->drupalPost($path, $edit, t('Save')); $last_fid = $this->getLastFileId(); - $this->assertTrue($last_fid > $last_fid_prior, t('New file got saved.')); - $this->assertRaw(t('The file id is %fid.', array('%fid' => $last_fid)), t('Submit handler has correct file info.')); + $this->assertTrue($last_fid > $last_fid_prior, 'New file got saved.'); + $this->assertRaw(t('The file id is %fid.', array('%fid' => $last_fid)), 'Submit handler has correct file info.'); // Submit no new input, but with a default file. $this->drupalPost($path . '/' . $last_fid, array(), t('Save')); - $this->assertRaw(t('The file id is %fid.', array('%fid' => $last_fid)), t('Empty submission did not change an existing file.')); + $this->assertRaw(t('The file id is %fid.', array('%fid' => $last_fid)), 'Empty submission did not change an existing file.'); // Now, test the Upload and Remove buttons, with and without Ajax. foreach (array(FALSE, TRUE) as $ajax) { @@ -67,9 +67,9 @@ class FileManagedFileElementTest extends FileFieldTestBase { $this->drupalPost(NULL, $edit, t('Upload')); } $last_fid = $this->getLastFileId(); - $this->assertTrue($last_fid > $last_fid_prior, t('New file got uploaded.')); + $this->assertTrue($last_fid > $last_fid_prior, 'New file got uploaded.'); $this->drupalPost(NULL, array(), t('Save')); - $this->assertRaw(t('The file id is %fid.', array('%fid' => $last_fid)), t('Submit handler has correct file info.')); + $this->assertRaw(t('The file id is %fid.', array('%fid' => $last_fid)), 'Submit handler has correct file info.'); // Remove, then Submit. $this->drupalGet($path . '/' . $last_fid); @@ -80,7 +80,7 @@ class FileManagedFileElementTest extends FileFieldTestBase { $this->drupalPost(NULL, array(), t('Remove')); } $this->drupalPost(NULL, array(), t('Save')); - $this->assertRaw(t('The file id is %fid.', array('%fid' => 0)), t('Submission after file removal was successful.')); + $this->assertRaw(t('The file id is %fid.', array('%fid' => 0)), 'Submission after file removal was successful.'); // Upload, then Remove, then Submit. $this->drupalGet($path); @@ -94,7 +94,7 @@ class FileManagedFileElementTest extends FileFieldTestBase { $this->drupalPost(NULL, array(), t('Remove')); } $this->drupalPost(NULL, array(), t('Save')); - $this->assertRaw(t('The file id is %fid.', array('%fid' => 0)), t('Submission after file upload and removal was successful.')); + $this->assertRaw(t('The file id is %fid.', array('%fid' => 0)), 'Submission after file upload and removal was successful.'); } } } diff --git a/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php b/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php index b449f8f..5e9ef26 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php @@ -56,7 +56,7 @@ abstract class FileManagedTestBase extends FileTestBase { $this->assertTrue(FALSE, t('Unexpected hooks were called: %unexpected.', array('%unexpected' => empty($unexpected) ? t('(none)') : implode(', ', $unexpected)))); } else { - $this->assertTrue(TRUE, t('No unexpected hooks were called.')); + $this->assertTrue(TRUE, 'No unexpected hooks were called.'); } } diff --git a/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php b/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php index 2febd5f..ef810d6 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php @@ -55,10 +55,10 @@ class FilePrivateTest extends FileFieldTestBase { $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); // Ensure the file can be downloaded. $this->drupalGet(file_create_url($node_file->uri)); - $this->assertResponse(200, t('Confirmed that the generated URL is correct by downloading the shipped file.')); + $this->assertResponse(200, 'Confirmed that the generated URL is correct by downloading the shipped file.'); $this->drupalLogOut(); $this->drupalGet(file_create_url($node_file->uri)); - $this->assertResponse(403, t('Confirmed that access is denied for the file without the needed permission.')); + $this->assertResponse(403, 'Confirmed that access is denied for the file without the needed permission.'); // Test with the field that should deny access through field access. $this->drupalLogin($this->admin_user); @@ -67,6 +67,6 @@ class FilePrivateTest extends FileFieldTestBase { $node_file = file_load($node->{$no_access_field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); // Ensure the file cannot be downloaded. $this->drupalGet(file_create_url($node_file->uri)); - $this->assertResponse(403, t('Confirmed that access is denied for the file without view field access permission.')); + $this->assertResponse(403, 'Confirmed that access is denied for the file without view field access permission.'); } } diff --git a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php index 4d56b7b..25ee425 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php @@ -62,7 +62,7 @@ class FileTokenReplaceTest extends FileFieldTestBase { $tests['[file:owner:uid]'] = $file->uid; // Test to make sure that we generated something for each token. - $this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.')); + $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { $output = token_replace($input, array('file' => $file), array('langcode' => $language_interface->langcode)); diff --git a/core/modules/file/lib/Drupal/file/Tests/MoveTest.php b/core/modules/file/lib/Drupal/file/Tests/MoveTest.php index 15868b1..c1ea609 100644 --- a/core/modules/file/lib/Drupal/file/Tests/MoveTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/MoveTest.php @@ -32,9 +32,9 @@ class MoveTest extends FileManagedTestBase { $result = file_move(clone $source, $desired_filepath, FILE_EXISTS_ERROR); // Check the return status and that the contents changed. - $this->assertTrue($result, t('File moved successfully.')); + $this->assertTrue($result, 'File moved successfully.'); $this->assertFalse(file_exists($source->uri)); - $this->assertEqual($contents, file_get_contents($result->uri), t('Contents of file correctly written.')); + $this->assertEqual($contents, file_get_contents($result->uri), 'Contents of file correctly written.'); // Check that the correct hooks were called. $this->assertFileHooksCalled(array('move', 'load', 'update')); @@ -45,7 +45,7 @@ class MoveTest extends FileManagedTestBase { // Reload the file from the database and check that the changes were // actually saved. $loaded_file = file_load($result->fid, TRUE); - $this->assertTrue($loaded_file, t('File can be loaded from the database.')); + $this->assertTrue($loaded_file, 'File can be loaded from the database.'); $this->assertFileUnchanged($result, $loaded_file); } @@ -64,9 +64,9 @@ class MoveTest extends FileManagedTestBase { $result = file_move(clone $source, $target->uri, FILE_EXISTS_RENAME); // Check the return status and that the contents changed. - $this->assertTrue($result, t('File moved successfully.')); + $this->assertTrue($result, 'File moved successfully.'); $this->assertFalse(file_exists($source->uri)); - $this->assertEqual($contents, file_get_contents($result->uri), t('Contents of file correctly written.')); + $this->assertEqual($contents, file_get_contents($result->uri), 'Contents of file correctly written.'); // Check that the correct hooks were called. $this->assertFileHooksCalled(array('move', 'load', 'update')); @@ -99,9 +99,9 @@ class MoveTest extends FileManagedTestBase { $result = file_move(clone $source, $target->uri, FILE_EXISTS_REPLACE); // Look at the results. - $this->assertEqual($contents, file_get_contents($result->uri), t('Contents of file were overwritten.')); + $this->assertEqual($contents, file_get_contents($result->uri), 'Contents of file were overwritten.'); $this->assertFalse(file_exists($source->uri)); - $this->assertTrue($result, t('File moved successfully.')); + $this->assertTrue($result, 'File moved successfully.'); // Check that the correct hooks were called. $this->assertFileHooksCalled(array('move', 'update', 'delete', 'load')); @@ -127,8 +127,8 @@ class MoveTest extends FileManagedTestBase { // Copy the file over itself. Clone the object so we don't have to worry // about the function changing our reference copy. $result = file_move(clone $source, $source->uri, FILE_EXISTS_REPLACE); - $this->assertFalse($result, t('File move failed.')); - $this->assertEqual($contents, file_get_contents($source->uri), t('Contents of file were not altered.')); + $this->assertFalse($result, 'File move failed.'); + $this->assertEqual($contents, file_get_contents($source->uri), 'Contents of file were not altered.'); // Check that no hooks were called while failing. $this->assertFileHooksCalled(array()); @@ -153,9 +153,9 @@ class MoveTest extends FileManagedTestBase { $result = file_move(clone $source, $target->uri, FILE_EXISTS_ERROR); // Check the return status and that the contents did not change. - $this->assertFalse($result, t('File move failed.')); + $this->assertFalse($result, 'File move failed.'); $this->assertTrue(file_exists($source->uri)); - $this->assertEqual($contents, file_get_contents($target->uri), t('Contents of file were not altered.')); + $this->assertEqual($contents, file_get_contents($target->uri), 'Contents of file were not altered.'); // Check that no hooks were called while failing. $this->assertFileHooksCalled(array()); diff --git a/core/modules/file/lib/Drupal/file/Tests/SaveDataTest.php b/core/modules/file/lib/Drupal/file/Tests/SaveDataTest.php index ecdb201..42e5973 100644 --- a/core/modules/file/lib/Drupal/file/Tests/SaveDataTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/SaveDataTest.php @@ -26,12 +26,12 @@ class SaveDataTest extends FileManagedTestBase { $contents = $this->randomName(8); $result = file_save_data($contents); - $this->assertTrue($result, t('Unnamed file saved correctly.')); + $this->assertTrue($result, 'Unnamed file saved correctly.'); $this->assertEqual(file_default_scheme(), file_uri_scheme($result->uri), t("File was placed in Drupal's files directory.")); $this->assertEqual($result->filename, drupal_basename($result->uri), t("Filename was set to the file's basename.")); - $this->assertEqual($contents, file_get_contents($result->uri), t('Contents of the file are correct.')); - $this->assertEqual($result->filemime, 'application/octet-stream', t('A MIME type was set.')); + $this->assertEqual($contents, file_get_contents($result->uri), 'Contents of the file are correct.'); + $this->assertEqual($result->filemime, 'application/octet-stream', 'A MIME type was set.'); $this->assertEqual($result->status, FILE_STATUS_PERMANENT, t("The file's status was set to permanent.")); // Check that the correct hooks were called. @@ -51,12 +51,12 @@ class SaveDataTest extends FileManagedTestBase { $filename = 'Текстовый файл.txt'; $result = file_save_data($contents, 'public://' . $filename); - $this->assertTrue($result, t('Unnamed file saved correctly.')); + $this->assertTrue($result, 'Unnamed file saved correctly.'); $this->assertEqual('public', file_uri_scheme($result->uri), t("File was placed in Drupal's files directory.")); - $this->assertEqual($filename, drupal_basename($result->uri), t('File was named correctly.')); - $this->assertEqual($contents, file_get_contents($result->uri), t('Contents of the file are correct.')); - $this->assertEqual($result->filemime, 'text/plain', t('A MIME type was set.')); + $this->assertEqual($filename, drupal_basename($result->uri), 'File was named correctly.'); + $this->assertEqual($contents, file_get_contents($result->uri), 'Contents of the file are correct.'); + $this->assertEqual($result->filemime, 'text/plain', 'A MIME type was set.'); $this->assertEqual($result->status, FILE_STATUS_PERMANENT, t("The file's status was set to permanent.")); // Check that the correct hooks were called. @@ -103,12 +103,12 @@ class SaveDataTest extends FileManagedTestBase { $contents = $this->randomName(8); $result = file_save_data($contents, $existing->uri, FILE_EXISTS_REPLACE); - $this->assertTrue($result, t('File saved successfully.')); + $this->assertTrue($result, 'File saved successfully.'); $this->assertEqual('public', file_uri_scheme($result->uri), t("File was placed in Drupal's files directory.")); - $this->assertEqual($result->filename, $existing->filename, t('Filename was set to the basename of the existing file, rather than preserving the original name.')); - $this->assertEqual($contents, file_get_contents($result->uri), t('Contents of the file are correct.')); - $this->assertEqual($result->filemime, 'application/octet-stream', t('A MIME type was set.')); + $this->assertEqual($result->filename, $existing->filename, 'Filename was set to the basename of the existing file, rather than preserving the original name.'); + $this->assertEqual($contents, file_get_contents($result->uri), 'Contents of the file are correct.'); + $this->assertEqual($result->filemime, 'application/octet-stream', 'A MIME type was set.'); $this->assertEqual($result->status, FILE_STATUS_PERMANENT, t("The file's status was set to permanent.")); // Check that the correct hooks were called. @@ -130,8 +130,8 @@ class SaveDataTest extends FileManagedTestBase { // Check the overwrite error. $result = file_save_data('asdf', $existing->uri, FILE_EXISTS_ERROR); - $this->assertFalse($result, t('Overwriting a file fails when FILE_EXISTS_ERROR is specified.')); - $this->assertEqual($contents, file_get_contents($existing->uri), t('Contents of existing file were unchanged.')); + $this->assertFalse($result, 'Overwriting a file fails when FILE_EXISTS_ERROR is specified.'); + $this->assertEqual($contents, file_get_contents($existing->uri), 'Contents of existing file were unchanged.'); // Check that no hooks were called while failing. $this->assertFileHooksCalled(array()); diff --git a/core/modules/file/lib/Drupal/file/Tests/SaveUploadTest.php b/core/modules/file/lib/Drupal/file/Tests/SaveUploadTest.php index c2adbd6..599f3ed 100644 --- a/core/modules/file/lib/Drupal/file/Tests/SaveUploadTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/SaveUploadTest.php @@ -56,8 +56,8 @@ class SaveUploadTest extends FileManagedTestBase { 'files[file_test_upload]' => drupal_realpath($this->image->uri), ); $this->drupalPost('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, t('Received a 200 response for posted test file.')); - $this->assertRaw(t('You WIN!'), t('Found the success message.')); + $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertRaw(t('You WIN!'), 'Found the success message.'); // Check that the correct hooks were called then clean out the hook // counters. @@ -70,9 +70,9 @@ class SaveUploadTest extends FileManagedTestBase { */ function testNormal() { $max_fid_after = db_query('SELECT MAX(fid) AS fid FROM {file_managed}')->fetchField(); - $this->assertTrue($max_fid_after > $this->maxFidBefore, t('A new file was created.')); + $this->assertTrue($max_fid_after > $this->maxFidBefore, 'A new file was created.'); $file1 = file_load($max_fid_after); - $this->assertTrue($file1, t('Loaded the file.')); + $this->assertTrue($file1, 'Loaded the file.'); // MIME type of the uploaded image may be either image/jpeg or image/png. $this->assertEqual(substr($file1->filemime, 0, 5), 'image', 'A MIME type was set.'); @@ -84,7 +84,7 @@ class SaveUploadTest extends FileManagedTestBase { $image2 = current($this->drupalGetTestFiles('image')); $edit = array('files[file_test_upload]' => drupal_realpath($image2->uri)); $this->drupalPost('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, t('Received a 200 response for posted test file.')); + $this->assertResponse(200, 'Received a 200 response for posted test file.'); $this->assertRaw(t('You WIN!')); $max_fid_after = db_query('SELECT MAX(fid) AS fid FROM {file_managed}')->fetchField(); @@ -98,8 +98,8 @@ class SaveUploadTest extends FileManagedTestBase { // Load both files using file_load_multiple(). $files = file_load_multiple(array($file1->fid, $file2->fid)); - $this->assertTrue(isset($files[$file1->fid]), t('File was loaded successfully')); - $this->assertTrue(isset($files[$file2->fid]), t('File was loaded successfully')); + $this->assertTrue(isset($files[$file1->fid]), 'File was loaded successfully'); + $this->assertTrue(isset($files[$file2->fid]), 'File was loaded successfully'); // Upload a third file to a subdirectory. $image3 = current($this->drupalGetTestFiles('image')); @@ -110,7 +110,7 @@ class SaveUploadTest extends FileManagedTestBase { 'file_subdir' => $dir, ); $this->drupalPost('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, t('Received a 200 response for posted test file.')); + $this->assertResponse(200, 'Received a 200 response for posted test file.'); $this->assertRaw(t('You WIN!')); $this->assertTrue(is_file('temporary://' . $dir . '/' . trim(drupal_basename($image3_realpath)))); } @@ -131,10 +131,10 @@ class SaveUploadTest extends FileManagedTestBase { ); $this->drupalPost('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, t('Received a 200 response for posted test file.')); + $this->assertResponse(200, 'Received a 200 response for posted test file.'); $message = t('Only files with the following extensions are allowed:') . ' ' . $extensions . ''; $this->assertRaw($message, t('Can\'t upload a disallowed extension')); - $this->assertRaw(t('Epic upload FAIL!'), t('Found the failure message.')); + $this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.'); // Check that the correct hooks were called. $this->assertFileHooksCalled(array('validate')); @@ -151,9 +151,9 @@ class SaveUploadTest extends FileManagedTestBase { ); $this->drupalPost('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, t('Received a 200 response for posted test file.')); - $this->assertNoRaw(t('Only files with the following extensions are allowed:'), t('Can upload an allowed extension.')); - $this->assertRaw(t('You WIN!'), t('Found the success message.')); + $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertNoRaw(t('Only files with the following extensions are allowed:'), 'Can upload an allowed extension.'); + $this->assertRaw(t('You WIN!'), 'Found the success message.'); // Check that the correct hooks were called. $this->assertFileHooksCalled(array('validate', 'load', 'update')); @@ -168,9 +168,9 @@ class SaveUploadTest extends FileManagedTestBase { 'allow_all_extensions' => TRUE, ); $this->drupalPost('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, t('Received a 200 response for posted test file.')); - $this->assertNoRaw(t('Only files with the following extensions are allowed:'), t('Can upload any extension.')); - $this->assertRaw(t('You WIN!'), t('Found the success message.')); + $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertNoRaw(t('Only files with the following extensions are allowed:'), 'Can upload any extension.'); + $this->assertRaw(t('You WIN!'), 'Found the success message.'); // Check that the correct hooks were called. $this->assertFileHooksCalled(array('validate', 'load', 'update')); @@ -190,11 +190,11 @@ class SaveUploadTest extends FileManagedTestBase { ); $this->drupalPost('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, t('Received a 200 response for posted test file.')); + $this->assertResponse(200, 'Received a 200 response for posted test file.'); $message = t('For security reasons, your upload has been renamed to') . ' ' . $this->phpfile->filename . '.txt' . ''; - $this->assertRaw($message, t('Dangerous file was renamed.')); + $this->assertRaw($message, 'Dangerous file was renamed.'); $this->assertRaw(t('File MIME type is text/plain.'), t('Dangerous file\'s MIME type was changed.')); - $this->assertRaw(t('You WIN!'), t('Found the success message.')); + $this->assertRaw(t('You WIN!'), 'Found the success message.'); // Check that the correct hooks were called. $this->assertFileHooksCalled(array('validate', 'insert')); @@ -206,10 +206,10 @@ class SaveUploadTest extends FileManagedTestBase { file_test_reset(); $this->drupalPost('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, t('Received a 200 response for posted test file.')); - $this->assertNoRaw(t('For security reasons, your upload has been renamed'), t('Found no security message.')); - $this->assertRaw(t('File name is !filename', array('!filename' => $this->phpfile->filename)), t('Dangerous file was not renamed when insecure uploads is TRUE.')); - $this->assertRaw(t('You WIN!'), t('Found the success message.')); + $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertNoRaw(t('For security reasons, your upload has been renamed'), 'Found no security message.'); + $this->assertRaw(t('File name is !filename', array('!filename' => $this->phpfile->filename)), 'Dangerous file was not renamed when insecure uploads is TRUE.'); + $this->assertRaw(t('You WIN!'), 'Found the success message.'); // Check that the correct hooks were called. $this->assertFileHooksCalled(array('validate', 'insert')); @@ -240,10 +240,10 @@ class SaveUploadTest extends FileManagedTestBase { $munged_filename .= '_.' . $this->image_extension; $this->drupalPost('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, t('Received a 200 response for posted test file.')); - $this->assertRaw(t('For security reasons, your upload has been renamed'), t('Found security message.')); - $this->assertRaw(t('File name is !filename', array('!filename' => $munged_filename)), t('File was successfully munged.')); - $this->assertRaw(t('You WIN!'), t('Found the success message.')); + $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertRaw(t('For security reasons, your upload has been renamed'), 'Found security message.'); + $this->assertRaw(t('File name is !filename', array('!filename' => $munged_filename)), 'File was successfully munged.'); + $this->assertRaw(t('You WIN!'), 'Found the success message.'); // Check that the correct hooks were called. $this->assertFileHooksCalled(array('validate', 'insert')); @@ -258,10 +258,10 @@ class SaveUploadTest extends FileManagedTestBase { ); $this->drupalPost('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, t('Received a 200 response for posted test file.')); - $this->assertNoRaw(t('For security reasons, your upload has been renamed'), t('Found no security message.')); - $this->assertRaw(t('File name is !filename', array('!filename' => $this->image->filename)), t('File was not munged when allowing any extension.')); - $this->assertRaw(t('You WIN!'), t('Found the success message.')); + $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertNoRaw(t('For security reasons, your upload has been renamed'), 'Found no security message.'); + $this->assertRaw(t('File name is !filename', array('!filename' => $this->image->filename)), 'File was not munged when allowing any extension.'); + $this->assertRaw(t('You WIN!'), 'Found the success message.'); // Check that the correct hooks were called. $this->assertFileHooksCalled(array('validate', 'insert')); @@ -276,8 +276,8 @@ class SaveUploadTest extends FileManagedTestBase { 'files[file_test_upload]' => drupal_realpath($this->image->uri) ); $this->drupalPost('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, t('Received a 200 response for posted test file.')); - $this->assertRaw(t('You WIN!'), t('Found the success message.')); + $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertRaw(t('You WIN!'), 'Found the success message.'); // Check that the correct hooks were called. $this->assertFileHooksCalled(array('validate', 'insert')); @@ -292,8 +292,8 @@ class SaveUploadTest extends FileManagedTestBase { 'files[file_test_upload]' => drupal_realpath($this->image->uri) ); $this->drupalPost('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, t('Received a 200 response for posted test file.')); - $this->assertRaw(t('You WIN!'), t('Found the success message.')); + $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertRaw(t('You WIN!'), 'Found the success message.'); // Check that the correct hooks were called. $this->assertFileHooksCalled(array('validate', 'load', 'update')); @@ -308,8 +308,8 @@ class SaveUploadTest extends FileManagedTestBase { 'files[file_test_upload]' => drupal_realpath($this->image->uri) ); $this->drupalPost('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, t('Received a 200 response for posted test file.')); - $this->assertRaw(t('Epic upload FAIL!'), t('Found the failure message.')); + $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.'); // Check that the no hooks were called while failing. $this->assertFileHooksCalled(array()); @@ -320,6 +320,6 @@ class SaveUploadTest extends FileManagedTestBase { */ function testNoUpload() { $this->drupalPost('file-test/upload', array(), t('Submit')); - $this->assertNoRaw(t('Epic upload FAIL!'), t('Failure message not found.')); + $this->assertNoRaw(t('Epic upload FAIL!'), 'Failure message not found.'); } } diff --git a/core/modules/file/lib/Drupal/file/Tests/UsageTest.php b/core/modules/file/lib/Drupal/file/Tests/UsageTest.php index b3239fd..b12a726 100644 --- a/core/modules/file/lib/Drupal/file/Tests/UsageTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/UsageTest.php @@ -45,11 +45,11 @@ class UsageTest extends FileManagedTestBase { $usage = file_usage_list($file); - $this->assertEqual(count($usage['testing']), 2, t('Returned the correct number of items.')); - $this->assertTrue(isset($usage['testing']['foo'][1]), t('Returned the correct id.')); - $this->assertTrue(isset($usage['testing']['bar'][2]), t('Returned the correct id.')); - $this->assertEqual($usage['testing']['foo'][1], 1, t('Returned the correct count.')); - $this->assertEqual($usage['testing']['bar'][2], 2, t('Returned the correct count.')); + $this->assertEqual(count($usage['testing']), 2, 'Returned the correct number of items.'); + $this->assertTrue(isset($usage['testing']['foo'][1]), 'Returned the correct id.'); + $this->assertTrue(isset($usage['testing']['bar'][2]), 'Returned the correct id.'); + $this->assertEqual($usage['testing']['foo'][1], 1, 'Returned the correct count.'); + $this->assertEqual($usage['testing']['bar'][2], 2, 'Returned the correct count.'); } /** @@ -68,13 +68,13 @@ class UsageTest extends FileManagedTestBase { ->condition('f.fid', $file->fid) ->execute() ->fetchAllAssoc('id'); - $this->assertEqual(count($usage), 2, t('Created two records')); - $this->assertEqual($usage[1]->module, 'testing', t('Correct module')); - $this->assertEqual($usage[2]->module, 'testing', t('Correct module')); - $this->assertEqual($usage[1]->type, 'foo', t('Correct type')); - $this->assertEqual($usage[2]->type, 'bar', t('Correct type')); - $this->assertEqual($usage[1]->count, 1, t('Correct count')); - $this->assertEqual($usage[2]->count, 2, t('Correct count')); + $this->assertEqual(count($usage), 2, 'Created two records'); + $this->assertEqual($usage[1]->module, 'testing', 'Correct module'); + $this->assertEqual($usage[2]->module, 'testing', 'Correct module'); + $this->assertEqual($usage[1]->type, 'foo', 'Correct type'); + $this->assertEqual($usage[2]->type, 'bar', 'Correct type'); + $this->assertEqual($usage[1]->count, 1, 'Correct count'); + $this->assertEqual($usage[2]->count, 2, 'Correct count'); } /** @@ -99,7 +99,7 @@ class UsageTest extends FileManagedTestBase { ->condition('f.fid', $file->fid) ->execute() ->fetchField(); - $this->assertEqual(2, $count, t('The count was decremented correctly.')); + $this->assertEqual(2, $count, 'The count was decremented correctly.'); // Multiple decrement and removal. file_usage_delete($file, 'testing', 'bar', 2, 2); @@ -108,7 +108,7 @@ class UsageTest extends FileManagedTestBase { ->condition('f.fid', $file->fid) ->execute() ->fetchField(); - $this->assertIdentical(FALSE, $count, t('The count was removed entirely when empty.')); + $this->assertIdentical(FALSE, $count, 'The count was removed entirely when empty.'); // Non-existent decrement. file_usage_delete($file, 'testing', 'bar', 2); @@ -117,7 +117,7 @@ class UsageTest extends FileManagedTestBase { ->condition('f.fid', $file->fid) ->execute() ->fetchField(); - $this->assertIdentical(FALSE, $count, t('Decrementing non-exist record complete.')); + $this->assertIdentical(FALSE, $count, 'Decrementing non-exist record complete.'); } /** @@ -136,7 +136,7 @@ class UsageTest extends FileManagedTestBase { )) ->condition('fid', $temp_old->fid) ->execute(); - $this->assertTrue(file_exists($temp_old->uri), t('Old temp file was created correctly.')); + $this->assertTrue(file_exists($temp_old->uri), 'Old temp file was created correctly.'); // Temporary file that is less than DRUPAL_MAXIMUM_TEMP_FILE_AGE. $temp_new = file_save_data(''); @@ -144,7 +144,7 @@ class UsageTest extends FileManagedTestBase { ->fields(array('status' => 0)) ->condition('fid', $temp_new->fid) ->execute(); - $this->assertTrue(file_exists($temp_new->uri), t('New temp file was created correctly.')); + $this->assertTrue(file_exists($temp_new->uri), 'New temp file was created correctly.'); // Permanent file that is older than DRUPAL_MAXIMUM_TEMP_FILE_AGE. $perm_old = file_save_data(''); @@ -152,17 +152,17 @@ class UsageTest extends FileManagedTestBase { ->fields(array('timestamp' => 1)) ->condition('fid', $temp_old->fid) ->execute(); - $this->assertTrue(file_exists($perm_old->uri), t('Old permanent file was created correctly.')); + $this->assertTrue(file_exists($perm_old->uri), 'Old permanent file was created correctly.'); // Permanent file that is newer than DRUPAL_MAXIMUM_TEMP_FILE_AGE. $perm_new = file_save_data(''); - $this->assertTrue(file_exists($perm_new->uri), t('New permanent file was created correctly.')); + $this->assertTrue(file_exists($perm_new->uri), 'New permanent file was created correctly.'); // Run cron and then ensure that only the old, temp file was deleted. $this->cronRun(); - $this->assertFalse(file_exists($temp_old->uri), t('Old temp file was correctly removed.')); - $this->assertTrue(file_exists($temp_new->uri), t('New temp file was correctly ignored.')); - $this->assertTrue(file_exists($perm_old->uri), t('Old permanent file was correctly ignored.')); - $this->assertTrue(file_exists($perm_new->uri), t('New permanent file was correctly ignored.')); + $this->assertFalse(file_exists($temp_old->uri), 'Old temp file was correctly removed.'); + $this->assertTrue(file_exists($temp_new->uri), 'New temp file was correctly ignored.'); + $this->assertTrue(file_exists($perm_old->uri), 'Old permanent file was correctly ignored.'); + $this->assertTrue(file_exists($perm_new->uri), 'New permanent file was correctly ignored.'); } } diff --git a/core/modules/file/lib/Drupal/file/Tests/ValidateTest.php b/core/modules/file/lib/Drupal/file/Tests/ValidateTest.php index 2418382..faef73f 100644 --- a/core/modules/file/lib/Drupal/file/Tests/ValidateTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/ValidateTest.php @@ -26,7 +26,7 @@ class ValidateTest extends FileManagedTestBase { $file = $this->createFile(); // Empty validators. - $this->assertEqual(file_validate($file, array()), array(), t('Validating an empty array works successfully.')); + $this->assertEqual(file_validate($file, array()), array(), 'Validating an empty array works successfully.'); $this->assertFileHooksCalled(array('validate')); // Use the file_test.module's test validator to ensure that passing tests @@ -34,14 +34,14 @@ class ValidateTest extends FileManagedTestBase { file_test_reset(); file_test_set_return('validate', array()); $passing = array('file_test_validator' => array(array())); - $this->assertEqual(file_validate($file, $passing), array(), t('Validating passes.')); + $this->assertEqual(file_validate($file, $passing), array(), 'Validating passes.'); $this->assertFileHooksCalled(array('validate')); // Now test for failures in validators passed in and by hook_validate. file_test_reset(); file_test_set_return('validate', array('Epic fail')); $failing = array('file_test_validator' => array(array('Failed', 'Badly'))); - $this->assertEqual(file_validate($file, $failing), array('Failed', 'Badly', 'Epic fail'), t('Validating returns errors.')); + $this->assertEqual(file_validate($file, $failing), array('Failed', 'Badly', 'Epic fail'), 'Validating returns errors.'); $this->assertFileHooksCalled(array('validate')); } }