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 @@ function testNormal() { $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 @@ function testExistingRename() { $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 @@ function testExistingReplace() { $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 @@ function testExistingError() { $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 20266d4..1d2268c 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 @@ function testUnused() { $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 @@ function testInUse() { file_usage()->delete($file, 'testing', 'test', 1); $usage = file_usage()->listUsage($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 @@ function testInUse() { file_usage()->delete($file, 'testing', 'test', 1); $usage = file_usage()->listUsage($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 @@ function testInUse() { // 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 @@ function testPublicFileTransfer() { // 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 @@ function testPrivateFileTransfer() { 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 @@ private function checkUrl($scheme, $directory, $filename, $expected_url) { $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 @@ private function checkUrl($scheme, $directory, $filename, $expected_url) { $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..6629057 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php @@ -47,7 +47,7 @@ function testNodeDisplay() { ); $this->drupalPost("admin/structure/types/manage/$type_name/display", $edit, t('Save')); $this->drupalGet('node/' . $node->nid); - $this->assertNoText($field_name, t('Field label is hidden when no file attached for formatter %formatter', array('%formatter' => $formatter))); + $this->assertNoText($field_name, format_string('Field label is hidden when no file attached for formatter %formatter', array('%formatter' => $formatter))); } $test_file = $this->getTestFile('text'); @@ -60,13 +60,13 @@ function testNodeDisplay() { $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/FileFieldPathTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php index d963b89..7c47870 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php @@ -34,7 +34,7 @@ function testUploadPath() { // Check that the file was uploaded to the file root. $node = node_load($nid, TRUE); $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); - $this->assertPathMatch('public://' . $test_file->filename, $node_file->uri, t('The file %file was uploaded to the correct path.', array('%file' => $node_file->uri))); + $this->assertPathMatch('public://' . $test_file->filename, $node_file->uri, format_string('The file %file was uploaded to the correct path.', array('%file' => $node_file->uri))); // Change the path to contain multiple subdirectories. $field = $this->updateFileField($field_name, $type_name, array('file_directory' => 'foo/bar/baz')); @@ -45,7 +45,7 @@ function testUploadPath() { // Check that the file was uploaded into the subdirectory. $node = node_load($nid, TRUE); $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); - $this->assertPathMatch('public://foo/bar/baz/' . $test_file->filename, $node_file->uri, t('The file %file was uploaded to the correct path.', array('%file' => $node_file->uri))); + $this->assertPathMatch('public://foo/bar/baz/' . $test_file->filename, $node_file->uri, format_string('The file %file was uploaded to the correct path.', array('%file' => $node_file->uri))); // Check the path when used with tokens. // Change the path to contain multiple token directories. @@ -61,7 +61,7 @@ function testUploadPath() { // the user running the test case. $data = array('user' => $this->admin_user); $subdirectory = token_replace('[user:uid]/[user:name]', $data); - $this->assertPathMatch('public://' . $subdirectory . '/' . $test_file->filename, $node_file->uri, t('The file %file was uploaded to the correct path with token replacements.', array('%file' => $node_file->uri))); + $this->assertPathMatch('public://' . $subdirectory . '/' . $test_file->filename, $node_file->uri, format_string('The file %file was uploaded to the correct path with token replacements.', array('%file' => $node_file->uri))); } /** 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 @@ function testRevisions() { $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 @@ function testRevisions() { $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 @@ function testRevisions() { // 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 @@ function testRevisions() { ->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 @@ function testRevisions() { ->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..b2b11d6 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 @@ function uploadNodeFile($file, $field_name, $nid_or_type, $new_revision = TRUE, // 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. @@ -185,7 +185,7 @@ function replaceNodeFile($file, $field_name, $nid, $new_revision = TRUE) { * Asserts that a file exists physically on disk. */ function assertFileExists($file, $message = NULL) { - $message = isset($message) ? $message : t('File %file exists on the disk.', array('%file' => $file->uri)); + $message = isset($message) ? $message : format_string('File %file exists on the disk.', array('%file' => $file->uri)); $this->assertTrue(is_file($file->uri), $message); } @@ -195,7 +195,7 @@ function assertFileExists($file, $message = NULL) { function assertFileEntryExists($file, $message = NULL) { entity_get_controller('file')->resetCache(); $db_file = file_load($file->fid); - $message = isset($message) ? $message : t('File %file exists in database at the correct path.', array('%file' => $file->uri)); + $message = isset($message) ? $message : format_string('File %file exists in database at the correct path.', array('%file' => $file->uri)); $this->assertEqual($db_file->uri, $file->uri, $message); } @@ -203,7 +203,7 @@ function assertFileEntryExists($file, $message = NULL) { * Asserts that a file does not exist on disk. */ function assertFileNotExists($file, $message = NULL) { - $message = isset($message) ? $message : t('File %file exists on the disk.', array('%file' => $file->uri)); + $message = isset($message) ? $message : format_string('File %file exists on the disk.', array('%file' => $file->uri)); $this->assertFalse(is_file($file->uri), $message); } @@ -212,7 +212,7 @@ function assertFileNotExists($file, $message = NULL) { */ function assertFileEntryNotExists($file, $message) { entity_get_controller('file')->resetCache(); - $message = isset($message) ? $message : t('File %file exists in database at the correct path.', array('%file' => $file->uri)); + $message = isset($message) ? $message : format_string('File %file exists in database at the correct path.', array('%file' => $file->uri)); $this->assertFalse(file_load($file->fid), $message); } @@ -220,7 +220,7 @@ function assertFileEntryNotExists($file, $message) { * Asserts that a file's status is set to permanent in the database. */ function assertFileIsPermanent($file, $message = NULL) { - $message = isset($message) ? $message : t('File %file is permanent.', array('%file' => $file->uri)); + $message = isset($message) ? $message : format_string('File %file is permanent.', array('%file' => $file->uri)); $this->assertTrue($file->status == FILE_STATUS_PERMANENT, $message); } } diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php index 050931b..a8729a1 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php @@ -38,17 +38,17 @@ function testRequired() { $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); - $this->assertTrue($nid !== FALSE, t('uploadNodeFile(@test_file, @field_name, @type_name) succeeded', array('@test_file' => $test_file->uri, '@field_name' => $field_name, '@type_name' => $type_name))); + $this->assertTrue($nid !== FALSE, format_string('uploadNodeFile(@test_file, @field_name, @type_name) succeeded', array('@test_file' => $test_file->uri, '@field_name' => $field_name, '@type_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 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 @@ function testRequired() { // 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); @@ -99,13 +99,13 @@ function testFileMaxSize() { $nid = $this->uploadNodeFile($small_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 (%filesize) under the max limit (%maxsize).', array('%filesize' => format_size($small_file->filesize), '%maxsize' => $max_filesize))); - $this->assertFileEntryExists($node_file, t('File entry exists after uploading a file (%filesize) under the max limit (%maxsize).', array('%filesize' => format_size($small_file->filesize), '%maxsize' => $max_filesize))); + $this->assertFileExists($node_file, format_string('File exists after uploading a file (%filesize) under the max limit (%maxsize).', array('%filesize' => format_size($small_file->filesize), '%maxsize' => $max_filesize))); + $this->assertFileEntryExists($node_file, format_string('File entry exists after uploading a file (%filesize) under the max limit (%maxsize).', array('%filesize' => format_size($small_file->filesize), '%maxsize' => $max_filesize))); // Check that uploading the large file fails (1M limit). $nid = $this->uploadNodeFile($large_file, $field_name, $type_name); $error_message = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size($large_file->filesize), '%maxsize' => format_size($file_limit))); - $this->assertRaw($error_message, t('Node save failed when file (%filesize) exceeded the max upload size (%maxsize).', array('%filesize' => format_size($large_file->filesize), '%maxsize' => $max_filesize))); + $this->assertRaw($error_message, format_string('Node save failed when file (%filesize) exceeded the max upload size (%maxsize).', array('%filesize' => format_size($large_file->filesize), '%maxsize' => $max_filesize))); } // Turn off the max filesize. @@ -115,8 +115,8 @@ function testFileMaxSize() { $nid = $this->uploadNodeFile($large_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 (%filesize) with no max limit.', array('%filesize' => format_size($large_file->filesize)))); - $this->assertFileEntryExists($node_file, t('File entry exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->filesize)))); + $this->assertFileExists($node_file, format_string('File exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->filesize)))); + $this->assertFileEntryExists($node_file, format_string('File entry exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->filesize)))); // Remove our file field. field_delete_field($field_name); @@ -142,8 +142,8 @@ function testFileExtension() { $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 @@ function testFileExtension() { // 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 @@ function testFileExtension() { $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..d3264f8 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 @@ function testSingleValuedWidget() { $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 @@ function testSingleValuedWidget() { } // 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 @@ function testSingleValuedWidget() { // 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 @@ function testMultiValuedWidget() { $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; @@ -136,7 +136,7 @@ function testMultiValuedWidget() { // Ensure we have the expected number of Remove buttons, and that they // are numbered sequentially. $buttons = $this->xpath('//input[@type="submit" and @value="Remove"]'); - $this->assertTrue(is_array($buttons) && count($buttons) === $num_expected_remove_buttons, t('There are %n "Remove" buttons displayed (JSMode=%type).', array('%n' => $num_expected_remove_buttons, '%type' => $type))); + $this->assertTrue(is_array($buttons) && count($buttons) === $num_expected_remove_buttons, format_string('There are %n "Remove" buttons displayed (JSMode=%type).', array('%n' => $num_expected_remove_buttons, '%type' => $type))); foreach ($buttons as $i => $button) { $key = $i >= $remaining ? $i - $remaining : $i; $check_field_name = $field_name2; @@ -178,17 +178,17 @@ function testMultiValuedWidget() { // correct name. $upload_button_name = $current_field_name . '_' . LANGUAGE_NOT_SPECIFIED . '_' . $remaining . '_upload_button'; $buttons = $this->xpath('//input[@type="submit" and @value="Upload" and @name=:name]', array(':name' => $upload_button_name)); - $this->assertTrue(is_array($buttons) && count($buttons) == 1, t('The upload button is displayed with the correct name (JSMode=%type).', array('%type' => $type))); + $this->assertTrue(is_array($buttons) && count($buttons) == 1, format_string('The upload button is displayed with the correct name (JSMode=%type).', array('%type' => $type))); // Ensure only at most one button per field is displayed. $buttons = $this->xpath('//input[@type="submit" and @value="Upload"]'); $expected = $current_field_name == $field_name ? 1 : 2; - $this->assertTrue(is_array($buttons) && count($buttons) == $expected, t('After removing a file, only one "Upload" button for each possible field is displayed (JSMode=%type).', array('%type' => $type))); + $this->assertTrue(is_array($buttons) && count($buttons) == $expected, format_string('After removing a file, only one "Upload" button for each possible field is displayed (JSMode=%type).', array('%type' => $type))); } } // Ensure the page now has no Remove buttons. - $this->assertNoFieldByXPath('//input[@type="submit"]', t('Remove'), t('After removing all files, there is no "Remove" button displayed (JSMode=%type).', array('%type' => $type))); + $this->assertNoFieldByXPath('//input[@type="submit"]', t('Remove'), format_string('After removing all files, there is no "Remove" button displayed (JSMode=%type).', array('%type' => $type))); // Save the node and ensure it does not have any files. $this->drupalPost(NULL, array('title' => $this->randomName()), t('Save')); @@ -196,7 +196,7 @@ function testMultiValuedWidget() { 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 @@ function testPrivateFileSetting() { $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 @@ function testPrivateFileComment() { $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 @@ function testPrivateFileComment() { // 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 @@ function testManagedFile() { // 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 @@ function testManagedFile() { $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 @@ function testManagedFile() { $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 @@ function testManagedFile() { $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..268cd37 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php @@ -44,19 +44,19 @@ function assertFileHooksCalled($expected) { // Determine if there were any expected that were not called. $uncalled = array_diff($expected, $actual); if (count($uncalled)) { - $this->assertTrue(FALSE, t('Expected hooks %expected to be called but %uncalled was not called.', array('%expected' => implode(', ', $expected), '%uncalled' => implode(', ', $uncalled)))); + $this->assertTrue(FALSE, format_string('Expected hooks %expected to be called but %uncalled was not called.', array('%expected' => implode(', ', $expected), '%uncalled' => implode(', ', $uncalled)))); } else { - $this->assertTrue(TRUE, t('All the expected hooks were called: %expected', array('%expected' => empty($expected) ? t('(none)') : implode(', ', $expected)))); + $this->assertTrue(TRUE, format_string('All the expected hooks were called: %expected', array('%expected' => empty($expected) ? '(none)' : implode(', ', $expected)))); } // Determine if there were any unexpected calls. $unexpected = array_diff($actual, $expected); if (count($unexpected)) { - $this->assertTrue(FALSE, t('Unexpected hooks were called: %unexpected.', array('%unexpected' => empty($unexpected) ? t('(none)') : implode(', ', $unexpected)))); + $this->assertTrue(FALSE, format_string('Unexpected hooks were called: %unexpected.', array('%unexpected' => empty($unexpected) ? '(none)' : implode(', ', $unexpected)))); } else { - $this->assertTrue(TRUE, t('No unexpected hooks were called.')); + $this->assertTrue(TRUE, 'No unexpected hooks were called.'); } } @@ -75,13 +75,13 @@ function assertFileHookCalled($hook, $expected_count = 1, $message = NULL) { if (!isset($message)) { if ($actual_count == $expected_count) { - $message = t('hook_file_@name was called correctly.', array('@name' => $hook)); + $message = format_string('hook_file_@name was called correctly.', array('@name' => $hook)); } elseif ($expected_count == 0) { $message = format_plural($actual_count, 'hook_file_@name was not expected to be called but was actually called once.', 'hook_file_@name was not expected to be called but was actually called @count times.', array('@name' => $hook, '@count' => $actual_count)); } else { - $message = t('hook_file_@name was expected to be called %expected times but was called %actual times.', array('@name' => $hook, '%expected' => $expected_count, '%actual' => $actual_count)); + $message = format_string('hook_file_@name was expected to be called %expected times but was called %actual times.', array('@name' => $hook, '%expected' => $expected_count, '%actual' => $actual_count)); } } $this->assertEqual($actual_count, $expected_count, $message); @@ -114,7 +114,7 @@ function createFile($filepath = NULL, $contents = NULL, $scheme = NULL) { $file->status = 0; // Write the record directly rather than using the API so we don't invoke // the hooks. - $this->assertNotIdentical(drupal_write_record('file_managed', $file), FALSE, t('The file was added to the database.'), 'Create test file'); + $this->assertNotIdentical(drupal_write_record('file_managed', $file), FALSE, 'The file was added to the database.', 'Create test file'); return entity_create('file', (array) $file); } 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 @@ function testPrivateFile() { $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 @@ function testPrivateFile() { $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..783b9e2 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php @@ -62,11 +62,11 @@ function testFileTokenReplacement() { $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)); - $this->assertEqual($output, $expected, t('Sanitized file token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, format_string('Sanitized file token %token replaced.', array('%token' => $input))); } // Generate and test unsanitized tokens. @@ -77,7 +77,7 @@ function testFileTokenReplacement() { foreach ($tests as $input => $expected) { $output = token_replace($input, array('file' => $file), array('langcode' => $language_interface->langcode, 'sanitize' => FALSE)); - $this->assertEqual($output, $expected, t('Unsanitized file token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, format_string('Unsanitized file token %token replaced.', array('%token' => $input))); } } } diff --git a/core/modules/file/lib/Drupal/file/Tests/LoadTest.php b/core/modules/file/lib/Drupal/file/Tests/LoadTest.php index 833c260..992e298 100644 --- a/core/modules/file/lib/Drupal/file/Tests/LoadTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/LoadTest.php @@ -23,7 +23,7 @@ public static function getInfo() { * Try to load a non-existent file by fid. */ function testLoadMissingFid() { - $this->assertFalse(file_load(-1), t("Try to load an invalid fid fails.")); + $this->assertFalse(file_load(-1), 'Try to load an invalid fid fails.'); $this->assertFileHooksCalled(array()); } @@ -32,7 +32,7 @@ function testLoadMissingFid() { */ function testLoadMissingFilepath() { $files = entity_load_multiple_by_properties('file', array('uri' => 'foobar://misc/druplicon.png')); - $this->assertFalse(reset($files), t("Try to load a file that doesn't exist in the database fails.")); + $this->assertFalse(reset($files), "Try to load a file that doesn't exist in the database fails."); $this->assertFileHooksCalled(array()); } @@ -41,7 +41,7 @@ function testLoadMissingFilepath() { */ function testLoadInvalidStatus() { $files = entity_load_multiple_by_properties('file', array('status' => -99)); - $this->assertFalse(reset($files), t("Trying to load a file with an invalid status fails.")); + $this->assertFalse(reset($files), 'Trying to load a file with an invalid status fails.'); $this->assertFileHooksCalled(array()); } @@ -54,13 +54,13 @@ function testSingleValues() { $by_fid_file = file_load($file->fid); $this->assertFileHookCalled('load'); - $this->assertTrue(is_object($by_fid_file), t('file_load() returned an object.')); - $this->assertEqual($by_fid_file->fid, $file->fid, t("Loading by fid got the same fid."), 'File'); - $this->assertEqual($by_fid_file->uri, $file->uri, t("Loading by fid got the correct filepath."), 'File'); - $this->assertEqual($by_fid_file->filename, $file->filename, t("Loading by fid got the correct filename."), 'File'); - $this->assertEqual($by_fid_file->filemime, $file->filemime, t("Loading by fid got the correct MIME type."), 'File'); - $this->assertEqual($by_fid_file->status, $file->status, t("Loading by fid got the correct status."), 'File'); - $this->assertTrue($by_fid_file->file_test['loaded'], t('file_test_file_load() was able to modify the file during load.')); + $this->assertTrue(is_object($by_fid_file), 'file_load() returned an object.'); + $this->assertEqual($by_fid_file->fid, $file->fid, 'Loading by fid got the same fid.', 'File'); + $this->assertEqual($by_fid_file->uri, $file->uri, 'Loading by fid got the correct filepath.', 'File'); + $this->assertEqual($by_fid_file->filename, $file->filename, 'Loading by fid got the correct filename.', 'File'); + $this->assertEqual($by_fid_file->filemime, $file->filemime, 'Loading by fid got the correct MIME type.', 'File'); + $this->assertEqual($by_fid_file->status, $file->status, 'Loading by fid got the correct status.', 'File'); + $this->assertTrue($by_fid_file->file_test['loaded'], 'file_test_file_load() was able to modify the file during load.'); } /** @@ -74,18 +74,18 @@ function testMultiple() { file_test_reset(); $by_path_files = entity_load_multiple_by_properties('file', array('uri' => $file->uri)); $this->assertFileHookCalled('load'); - $this->assertEqual(1, count($by_path_files), t('file_load_multiple() returned an array of the correct size.')); + $this->assertEqual(1, count($by_path_files), 'file_load_multiple() returned an array of the correct size.'); $by_path_file = reset($by_path_files); - $this->assertTrue($by_path_file->file_test['loaded'], t('file_test_file_load() was able to modify the file during load.')); - $this->assertEqual($by_path_file->fid, $file->fid, t("Loading by filepath got the correct fid."), 'File'); + $this->assertTrue($by_path_file->file_test['loaded'], 'file_test_file_load() was able to modify the file during load.'); + $this->assertEqual($by_path_file->fid, $file->fid, 'Loading by filepath got the correct fid.', 'File'); // Load by fid. file_test_reset(); $by_fid_files = file_load_multiple(array($file->fid)); $this->assertFileHookCalled('load'); - $this->assertEqual(1, count($by_fid_files), t('file_load_multiple() returned an array of the correct size.')); + $this->assertEqual(1, count($by_fid_files), 'file_load_multiple() returned an array of the correct size.'); $by_fid_file = reset($by_fid_files); - $this->assertTrue($by_fid_file->file_test['loaded'], t('file_test_file_load() was able to modify the file during load.')); - $this->assertEqual($by_fid_file->uri, $file->uri, t("Loading by fid got the correct filepath."), 'File'); + $this->assertTrue($by_fid_file->file_test['loaded'], 'file_test_file_load() was able to modify the file during load.'); + $this->assertEqual($by_fid_file->uri, $file->uri, 'Loading by fid got the correct filepath.', 'File'); } } diff --git a/core/modules/file/lib/Drupal/file/Tests/MoveTest.php b/core/modules/file/lib/Drupal/file/Tests/MoveTest.php index 15868b1..4f86a85 100644 --- a/core/modules/file/lib/Drupal/file/Tests/MoveTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/MoveTest.php @@ -32,20 +32,20 @@ function testNormal() { $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')); // Make sure we got the same file back. - $this->assertEqual($source->fid, $result->fid, t("Source file id's' %fid is unchanged after move.", array('%fid' => $source->fid))); + $this->assertEqual($source->fid, $result->fid, format_string("Source file id's' %fid is unchanged after move.", array('%fid' => $source->fid))); // 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 @@ function testExistingRename() { $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')); @@ -80,8 +80,8 @@ function testExistingRename() { // Compare the source and results. $loaded_source = file_load($source->fid, TRUE); - $this->assertEqual($loaded_source->fid, $result->fid, t("Returned file's id matches the source.")); - $this->assertNotEqual($loaded_source->uri, $source->uri, t("Returned file path has changed from the original.")); + $this->assertEqual($loaded_source->fid, $result->fid, "Returned file's id matches the source."); + $this->assertNotEqual($loaded_source->uri, $source->uri, 'Returned file path has changed from the original.'); } /** @@ -99,9 +99,9 @@ function testExistingReplace() { $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 @@ function testExistingReplaceSelf() { // 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 @@ function testExistingError() { $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..d4169ba 100644 --- a/core/modules/file/lib/Drupal/file/Tests/SaveDataTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/SaveDataTest.php @@ -26,13 +26,13 @@ function testWithoutFilename() { $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($result->status, FILE_STATUS_PERMANENT, t("The file's status was set to permanent.")); + $this->assertEqual(file_default_scheme(), file_uri_scheme($result->uri), "File was placed in Drupal's files directory."); + $this->assertEqual($result->filename, drupal_basename($result->uri), "Filename was set to the file's basename."); + $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, "The file's status was set to permanent."); // Check that the correct hooks were called. $this->assertFileHooksCalled(array('insert')); @@ -51,13 +51,13 @@ function testWithFilename() { $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($result->status, FILE_STATUS_PERMANENT, t("The file's status was set to permanent.")); + $this->assertEqual('public', file_uri_scheme($result->uri), "File was placed in Drupal's files directory."); + $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, "The file's status was set to permanent."); // Check that the correct hooks were called. $this->assertFileHooksCalled(array('insert')); @@ -75,13 +75,13 @@ function testExistingRename() { $contents = $this->randomName(8); $result = file_save_data($contents, $existing->uri, FILE_EXISTS_RENAME); - $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 source, rather than that of the renamed file.")); - $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->status, FILE_STATUS_PERMANENT, t("The file's status was set to permanent.")); + $this->assertEqual('public', file_uri_scheme($result->uri), "File was placed in Drupal's files directory."); + $this->assertEqual($result->filename, $existing->filename, 'Filename was set to the basename of the source, rather than that of the renamed file.'); + $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, "The file's status was set to permanent."); // Check that the correct hooks were called. $this->assertFileHooksCalled(array('insert')); @@ -103,13 +103,13 @@ function testExistingReplace() { $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->status, FILE_STATUS_PERMANENT, t("The file's status was set to permanent.")); + $this->assertEqual('public', file_uri_scheme($result->uri), "File was placed in Drupal's files directory."); + $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, "The file's status was set to permanent."); // Check that the correct hooks were called. $this->assertFileHooksCalled(array('load', 'update')); @@ -130,8 +130,8 @@ function testExistingError() { // 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/SaveTest.php b/core/modules/file/lib/Drupal/file/Tests/SaveTest.php index e2611e5..6249112 100644 --- a/core/modules/file/lib/Drupal/file/Tests/SaveTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/SaveTest.php @@ -37,13 +37,13 @@ function testFileSave() { // Check that the correct hooks were called. $this->assertFileHooksCalled(array('insert')); - $this->assertTrue($file->fid > 0, t("A new file ID is set when saving a new file to the database."), 'File'); + $this->assertTrue($file->fid > 0, 'A new file ID is set when saving a new file to the database.', 'File'); $loaded_file = db_query('SELECT * FROM {file_managed} f WHERE f.fid = :fid', array(':fid' => $file->fid))->fetchObject(); - $this->assertNotNull($loaded_file, t("Record exists in the database.")); - $this->assertEqual($loaded_file->status, $file->status, t("Status was saved correctly.")); - $this->assertEqual($file->filesize, filesize($file->uri), t("File size was set correctly."), 'File'); - $this->assertTrue($file->timestamp > 1, t("File size was set correctly."), 'File'); - $this->assertEqual($loaded_file->langcode, LANGUAGE_NOT_SPECIFIED, t("Langcode was defaulted correctly.")); + $this->assertNotNull($loaded_file, 'Record exists in the database.'); + $this->assertEqual($loaded_file->status, $file->status, 'Status was saved correctly.'); + $this->assertEqual($file->filesize, filesize($file->uri), 'File size was set correctly.', 'File'); + $this->assertTrue($file->timestamp > 1, 'File size was set correctly.', 'File'); + $this->assertEqual($loaded_file->langcode, LANGUAGE_NOT_SPECIFIED, 'Langcode was defaulted correctly.'); // Resave the file, updating the existing record. file_test_reset(); @@ -54,12 +54,12 @@ function testFileSave() { // Check that the correct hooks were called. $this->assertFileHooksCalled(array('load', 'update')); - $this->assertEqual($file->fid, $file->fid, t("The file ID of an existing file is not changed when updating the database."), 'File'); - $this->assertTrue($file->timestamp >= $file->timestamp, t("Timestamp didn't go backwards."), 'File'); + $this->assertEqual($file->fid, $file->fid, 'The file ID of an existing file is not changed when updating the database.', 'File'); + $this->assertTrue($file->timestamp >= $file->timestamp, 'Timestamp didnot go backwards.', 'File'); $loaded_file = db_query('SELECT * FROM {file_managed} f WHERE f.fid = :fid', array(':fid' => $file->fid))->fetchObject(); - $this->assertNotNull($loaded_file, t("Record still exists in the database."), 'File'); - $this->assertEqual($loaded_file->status, $file->status, t("Status was saved correctly.")); - $this->assertEqual($loaded_file->langcode, 'en', t("Langcode was saved correctly.")); + $this->assertNotNull($loaded_file, 'Record still exists in the database.', 'File'); + $this->assertEqual($loaded_file->status, $file->status, 'Status was saved correctly.'); + $this->assertEqual($loaded_file->langcode, 'en', 'Langcode was saved correctly.'); // Try to insert a second file with the same name apart from case insensitivity // to ensure the 'uri' index allows for filenames with different cases. diff --git a/core/modules/file/lib/Drupal/file/Tests/SaveUploadTest.php b/core/modules/file/lib/Drupal/file/Tests/SaveUploadTest.php index c2adbd6..ffd0f7c 100644 --- a/core/modules/file/lib/Drupal/file/Tests/SaveUploadTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/SaveUploadTest.php @@ -43,10 +43,10 @@ function setUp() { $this->image = entity_create('file', (array) current($image_files)); list(, $this->image_extension) = explode('.', $this->image->filename); - $this->assertTrue(is_file($this->image->uri), t("The image file we're going to upload exists.")); + $this->assertTrue(is_file($this->image->uri), 'The image file we are going to upload exists.'); $this->phpfile = current($this->drupalGetTestFiles('php')); - $this->assertTrue(is_file($this->phpfile->uri), t("The PHP file we're going to upload exists.")); + $this->assertTrue(is_file($this->phpfile->uri), 'The PHP file we are going to upload exists.'); $this->maxFidBefore = db_query('SELECT MAX(fid) AS fid FROM {file_managed}')->fetchField(); @@ -56,8 +56,8 @@ function setUp() { '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 @@ function setUp() { */ 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 @@ function testNormal() { $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 @@ function testNormal() { // 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 @@ function testNormal() { '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 @@ function testHandleExtension() { ); $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($message, 'Cannot upload a disallowed extension'); + $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 @@ function testHandleExtension() { ); $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 @@ function testHandleExtension() { '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 @@ function testHandleDangerousFile() { ); $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(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($message, 'Dangerous file was renamed.'); + $this->assertRaw(t('File MIME type is text/plain.'), "Dangerous file\'s MIME type was changed."); + $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 @@ function testHandleDangerousFile() { 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 @@ function testHandleFileMunge() { $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 @@ function testHandleFileMunge() { ); $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 @@ function testExistingRename() { '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 @@ function testExistingReplace() { '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 @@ function testExistingError() { '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 @@ function testExistingError() { */ 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 00c82ef..ac9f0a7 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 @@ function testGetUsage() { $usage = file_usage()->listUsage($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 @@ function testAddUsage() { ->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 @@ function testRemoveUsage() { ->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 @@ function testRemoveUsage() { ->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 @@ function testRemoveUsage() { ->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 @@ function testTempFileCleanup() { )) ->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 @@ function testTempFileCleanup() { ->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 @@ function testTempFileCleanup() { ->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 @@ function testCallerValidation() { $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 @@ function testCallerValidation() { 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')); } } diff --git a/core/modules/file/lib/Drupal/file/Tests/ValidatorTest.php b/core/modules/file/lib/Drupal/file/Tests/ValidatorTest.php index eeaa47b..37a5ccb 100644 --- a/core/modules/file/lib/Drupal/file/Tests/ValidatorTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/ValidatorTest.php @@ -37,24 +37,24 @@ function setUp() { function testFileValidateExtensions() { $file = entity_create('file', array('filename' => 'asdf.txt')); $errors = file_validate_extensions($file, 'asdf txt pork'); - $this->assertEqual(count($errors), 0, t('Valid extension accepted.'), 'File'); + $this->assertEqual(count($errors), 0, 'Valid extension accepted.', 'File'); $file->filename = 'asdf.txt'; $errors = file_validate_extensions($file, 'exe png'); - $this->assertEqual(count($errors), 1, t('Invalid extension blocked.'), 'File'); + $this->assertEqual(count($errors), 1, 'Invalid extension blocked.', 'File'); } /** * This ensures a specific file is actually an image. */ function testFileValidateIsImage() { - $this->assertTrue(file_exists($this->image->uri), t('The image being tested exists.'), 'File'); + $this->assertTrue(file_exists($this->image->uri), 'The image being tested exists.', 'File'); $errors = file_validate_is_image($this->image); - $this->assertEqual(count($errors), 0, t('No error reported for our image file.'), 'File'); + $this->assertEqual(count($errors), 0, 'No error reported for our image file.', 'File'); - $this->assertTrue(file_exists($this->non_image->uri), t('The non-image being tested exists.'), 'File'); + $this->assertTrue(file_exists($this->non_image->uri), 'The non-image being tested exists.', 'File'); $errors = file_validate_is_image($this->non_image); - $this->assertEqual(count($errors), 1, t('An error reported for our non-image file.'), 'File'); + $this->assertEqual(count($errors), 1, 'An error reported for our non-image file.', 'File'); } /** @@ -64,19 +64,19 @@ function testFileValidateIsImage() { function testFileValidateImageResolution() { // Non-images. $errors = file_validate_image_resolution($this->non_image); - $this->assertEqual(count($errors), 0, t("Shouldn't get any errors for a non-image file."), 'File'); + $this->assertEqual(count($errors), 0, 'Should not get any errors for a non-image file.', 'File'); $errors = file_validate_image_resolution($this->non_image, '50x50', '100x100'); - $this->assertEqual(count($errors), 0, t("Don't check the resolution on non files."), 'File'); + $this->assertEqual(count($errors), 0, 'Do not check the resolution on non files.', 'File'); // Minimum size. $errors = file_validate_image_resolution($this->image); - $this->assertEqual(count($errors), 0, t('No errors for an image when there is no minimum or maximum resolution.'), 'File'); + $this->assertEqual(count($errors), 0, 'No errors for an image when there is no minimum or maximum resolution.', 'File'); $errors = file_validate_image_resolution($this->image, 0, '200x1'); - $this->assertEqual(count($errors), 1, t("Got an error for an image that wasn't wide enough."), 'File'); + $this->assertEqual(count($errors), 1, 'Got an error for an image that was not wide enough.', 'File'); $errors = file_validate_image_resolution($this->image, 0, '1x200'); - $this->assertEqual(count($errors), 1, t("Got an error for an image that wasn't tall enough."), 'File'); + $this->assertEqual(count($errors), 1, 'Got an error for an image that was not tall enough.', 'File'); $errors = file_validate_image_resolution($this->image, 0, '200x200'); - $this->assertEqual(count($errors), 1, t('Small images report an error.'), 'File'); + $this->assertEqual(count($errors), 1, 'Small images report an error.', 'File'); // Maximum size. if (image_get_toolkit()) { @@ -85,18 +85,18 @@ function testFileValidateImageResolution() { $this->image->uri = 'temporary://druplicon.png'; $errors = file_validate_image_resolution($this->image, '10x5'); - $this->assertEqual(count($errors), 0, t('No errors should be reported when an oversized image can be scaled down.'), 'File'); + $this->assertEqual(count($errors), 0, 'No errors should be reported when an oversized image can be scaled down.', 'File'); $info = image_get_info($this->image->uri); - $this->assertTrue($info['width'] <= 10, t('Image scaled to correct width.'), 'File'); - $this->assertTrue($info['height'] <= 5, t('Image scaled to correct height.'), 'File'); + $this->assertTrue($info['width'] <= 10, 'Image scaled to correct width.', 'File'); + $this->assertTrue($info['height'] <= 5, 'Image scaled to correct height.', 'File'); drupal_unlink('temporary://druplicon.png'); } else { // TODO: should check that the error is returned if no toolkit is available. $errors = file_validate_image_resolution($this->image, '5x10'); - $this->assertEqual(count($errors), 1, t("Oversize images that can't be scaled get an error."), 'File'); + $this->assertEqual(count($errors), 1, 'Oversize images that cannot be scaled get an error.', 'File'); } } @@ -111,17 +111,17 @@ function testFileValidateNameLength() { $file->filename = str_repeat('x', 240); $this->assertEqual(strlen($file->filename), 240); $errors = file_validate_name_length($file); - $this->assertEqual(count($errors), 0, t('No errors reported for 240 length filename.'), 'File'); + $this->assertEqual(count($errors), 0, 'No errors reported for 240 length filename.', 'File'); // Add a filename with a length too long and test it. $file->filename = str_repeat('x', 241); $errors = file_validate_name_length($file); - $this->assertEqual(count($errors), 1, t('An error reported for 241 length filename.'), 'File'); + $this->assertEqual(count($errors), 1, 'An error reported for 241 length filename.', 'File'); // Add a filename with an empty string and test it. $file->filename = ''; $errors = file_validate_name_length($file); - $this->assertEqual(count($errors), 1, t('An error reported for 0 length filename.'), 'File'); + $this->assertEqual(count($errors), 1, 'An error reported for 0 length filename.', 'File'); } @@ -139,13 +139,13 @@ function testFileValidateSize() { // Create a file with a size of 1000 bytes, and quotas of only 1 byte. $file = entity_create('file', array('filesize' => 1000)); $errors = file_validate_size($file, 0, 0); - $this->assertEqual(count($errors), 0, t('No limits means no errors.'), 'File'); + $this->assertEqual(count($errors), 0, 'No limits means no errors.', 'File'); $errors = file_validate_size($file, 1, 0); - $this->assertEqual(count($errors), 1, t('Error for the file being over the limit.'), 'File'); + $this->assertEqual(count($errors), 1, 'Error for the file being over the limit.', 'File'); $errors = file_validate_size($file, 0, 1); - $this->assertEqual(count($errors), 1, t('Error for the user being over their limit.'), 'File'); + $this->assertEqual(count($errors), 1, 'Error for the user being over their limit.', 'File'); $errors = file_validate_size($file, 1, 1); - $this->assertEqual(count($errors), 2, t('Errors for both the file and their limit.'), 'File'); + $this->assertEqual(count($errors), 2, 'Errors for both the file and their limit.', 'File'); $user = $original_user; drupal_save_session(TRUE);