diff --git a/core/modules/file/lib/Drupal/file/Tests/CopyTest.php b/core/modules/file/lib/Drupal/file/Tests/CopyTest.php index 6aaa2ca..1c0dce6 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->getFileUri()), t('Contents of file were copied correctly.')); + $this->assertTrue($result, 'File copied successfully.'); + $this->assertEqual($contents, file_get_contents($result->getFileUri()), '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->getFileUri(), $desired_uri, t('The copied file entity has the desired filepath.')); - $this->assertTrue(file_exists($source->getFileUri()), t('The original file still exists.')); - $this->assertTrue(file_exists($result->getFileUri()), t('The copied file exists.')); + $this->assertEqual($result->getFileUri(), $desired_uri, 'The copied file entity has the desired filepath.'); + $this->assertTrue(file_exists($source->getFileUri()), 'The original file still exists.'); + $this->assertTrue(file_exists($result->getFileUri()), '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->getFileUri(), 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->getFileUri()), t('Contents of file were copied correctly.')); - $this->assertNotEqual($result->getFileUri(), $source->getFileUri(), t('Returned file path has changed from the original.')); + $this->assertTrue($result, 'File copied successfully.'); + $this->assertEqual($contents, file_get_contents($result->getFileUri()), 'Contents of file were copied correctly.'); + $this->assertNotEqual($result->getFileUri(), $source->getFileUri(), '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->getFileUri(), 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->getFileUri()), t('Contents of file were overwritten.')); + $this->assertTrue($result, 'File copied successfully.'); + $this->assertEqual($contents, file_get_contents($result->getFileUri()), '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->getFileUri(), 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->getFileUri()), t('Contents of file were not altered.')); + $this->assertFalse($result, 'File copy failed.'); + $this->assertEqual($contents, file_get_contents($target->getFileUri()), '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 3270f8c..9bd52bc 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->getFileUri()), t('File exists.')); + $this->assertTrue(is_file($file->getFileUri()), 'File exists.'); $file->delete(); $this->assertFileHooksCalled(array('delete')); - $this->assertFalse(file_exists($file->getFileUri()), t('Test file has actually been deleted.')); - $this->assertFalse(file_load($file->id()), t('File was removed from the database.')); + $this->assertFalse(file_exists($file->getFileUri()), 'Test file has actually been deleted.'); + $this->assertFalse(file_load($file->id()), '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->getFileUri()), t('File still exists on the disk.')); - $this->assertTrue(file_load($file->id()), 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->getFileUri()), 'File still exists on the disk.'); + $this->assertTrue(file_load($file->id()), '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->getFileUri()), 'File still exists on the disk.'); $file = file_load($file->id()); $this->assertTrue($file, 'File still exists in the database.'); @@ -72,7 +72,7 @@ function testInUse() { // system_cron() loads $this->assertFileHooksCalled(array('delete')); - $this->assertFalse(file_exists($file->getFileUri()), t('File has been deleted after its last usage was removed.')); - $this->assertFalse(file_load($file->id()), t('File was removed from the database.')); + $this->assertFalse(file_exists($file->getFileUri()), 'File has been deleted after its last usage was removed.'); + $this->assertFalse(file_load($file->id()), '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 41cad99..a116456 100644 --- a/core/modules/file/lib/Drupal/file/Tests/DownloadTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/DownloadTest.php @@ -37,17 +37,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->getFilename()); - $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.'); } /** @@ -65,21 +65,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.'); } /** @@ -141,7 +141,7 @@ private function checkUrl($scheme, $directory, $filename, $expected_url) { $file = $this->createFile($filepath, NULL, $scheme); $url = file_create_url($file->getFileUri()); - $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 @@ -151,7 +151,7 @@ private function checkUrl($scheme, $directory, $filename, $expected_url) { $this->drupalGet($url); if ($this->assertResponse(200) == 'pass') { - $this->assertRaw(file_get_contents($file->getFileUri()), t('Contents of the file are correct.')); + $this->assertRaw(file_get_contents($file->getFileUri()), '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 ebce0b1..8d73392 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php @@ -50,7 +50,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'); @@ -62,13 +62,13 @@ function testNodeDisplay() { $node = node_load($nid, TRUE); $node_file = file_load($node->{$field_name}[Language::LANGCODE_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::LANGCODE_NOT_SPECIFIED . '][0][display]' => FALSE); $this->drupalPost('node/' . $nid . '/edit', $edit, t('Save and keep published')); - $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.'); // Add a description and make sure that it is displayed. $description = $this->randomName(); diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php index efe7aa0..9055560 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php @@ -36,7 +36,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::LANGCODE_NOT_SPECIFIED][0]['fid']); - $this->assertPathMatch('public://' . $test_file->getFilename(), $node_file->getFileUri(), t('The file %file was uploaded to the correct path.', array('%file' => $node_file->getFileUri()))); + $this->assertPathMatch('public://' . $test_file->getFilename(), $node_file->getFileUri(), format_string('The file %file was uploaded to the correct path.', array('%file' => $node_file->getFileUri()))); // Change the path to contain multiple subdirectories. $this->updateFileField($field_name, $type_name, array('file_directory' => 'foo/bar/baz')); @@ -47,7 +47,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::LANGCODE_NOT_SPECIFIED][0]['fid'], TRUE); - $this->assertPathMatch('public://foo/bar/baz/' . $test_file->getFilename(), $node_file->getFileUri(), t('The file %file was uploaded to the correct path.', array('%file' => $node_file->getFileUri()))); + $this->assertPathMatch('public://foo/bar/baz/' . $test_file->getFilename(), $node_file->getFileUri(), format_string('The file %file was uploaded to the correct path.', array('%file' => $node_file->getFileUri()))); // Check the path when used with tokens. // Change the path to contain multiple token directories. @@ -63,7 +63,7 @@ function testUploadPath() { // the user running the test case. $data = array('user' => $this->admin_user); $subdirectory = \Drupal::token()->replace('[user:uid]/[user:name]', $data); - $this->assertPathMatch('public://' . $subdirectory . '/' . $test_file->getFilename(), $node_file->getFileUri(), t('The file %file was uploaded to the correct path with token replacements.', array('%file' => $node_file->getFileUri()))); + $this->assertPathMatch('public://' . $subdirectory . '/' . $test_file->getFilename(), $node_file->getFileUri(), format_string('The file %file was uploaded to the correct path with token replacements.', array('%file' => $node_file->getFileUri()))); } /** diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php index 2d8cc3a..0a5ffa4 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php @@ -49,26 +49,26 @@ function testRevisions() { $node = node_load($nid, TRUE); $node_file_r1 = file_load($node->{$field_name}[Language::LANGCODE_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::LANGCODE_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); $current_file = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']); - $this->assertEqual($node_file_r1->id(), $current_file->id(), 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->id(), $current_file->id(), '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. @@ -76,23 +76,23 @@ function testRevisions() { $node = node_load($nid, TRUE); $node_file_r3 = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']); $node_vid_r3 = $node->vid; - $this->assertEqual($node_file_r2->id(), $node_file_r3->id(), 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->id(), $node_file_r3->id(), '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::LANGCODE_NOT_SPECIFIED][0]['fid']); $node_vid_r4 = $node->vid; - $this->assertEqual($node_file_r1->id(), $node_file_r4->id(), 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->id(), $node_file_r4->id(), '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(); @@ -103,9 +103,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); @@ -127,8 +127,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')); @@ -141,7 +141,7 @@ function testRevisions() { ->condition('fid', $node_file_r1->id()) ->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 e501573..965c44d 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php @@ -155,7 +155,7 @@ function uploadNodeFile($file, $field_name, $nid_or_type, $new_revision = TRUE, $node->setNewRevision(); $node->save(); $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. @@ -201,7 +201,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->getFileUri())); + $message = isset($message) ? $message : format_string('File %file exists on the disk.', array('%file' => $file->getFileUri())); $this->assertTrue(is_file($file->getFileUri()), $message); } @@ -211,7 +211,7 @@ function assertFileExists($file, $message = NULL) { function assertFileEntryExists($file, $message = NULL) { $this->container->get('plugin.manager.entity')->getStorageController('file')->resetCache(); $db_file = file_load($file->id()); - $message = isset($message) ? $message : t('File %file exists in database at the correct path.', array('%file' => $file->getFileUri())); + $message = isset($message) ? $message : format_string('File %file exists in database at the correct path.', array('%file' => $file->getFileUri())); $this->assertEqual($db_file->getFileUri(), $file->getFileUri(), $message); } @@ -219,7 +219,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->getFileUri())); + $message = isset($message) ? $message : format_string('File %file exists on the disk.', array('%file' => $file->getFileUri())); $this->assertFalse(is_file($file->getFileUri()), $message); } @@ -228,7 +228,7 @@ function assertFileNotExists($file, $message = NULL) { */ function assertFileEntryNotExists($file, $message) { $this->container->get('plugin.manager.entity')->getStorageController('file')->resetCache(); - $message = isset($message) ? $message : t('File %file exists in database at the correct path.', array('%file' => $file->getFileUri())); + $message = isset($message) ? $message : format_string('File %file exists in database at the correct path.', array('%file' => $file->getFileUri())); $this->assertFalse(file_load($file->id()), $message); } @@ -236,7 +236,7 @@ function assertFileEntryNotExists($file, $message) { * Asserts that a file's status is set to permanent in the database. */ function assertFileIsPermanent(FileInterface $file, $message = NULL) { - $message = isset($message) ? $message : t('File %file is permanent.', array('%file' => $file->getFileUri())); + $message = isset($message) ? $message : format_string('File %file is permanent.', array('%file' => $file->getFileUri())); $this->assertTrue($file->isPermanent(), $message); } diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php index 174ba99..19029c4 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php @@ -39,17 +39,17 @@ function testRequired() { $langcode = Language::LANGCODE_NOT_SPECIFIED; $edit = array("title" => $this->randomName()); $this->drupalPost('node/add/' . $type_name, $edit, t('Save and publish')); - $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->getFileUri(), '@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->getFileUri(), '@field_name' => $field_name, '@type_name' => $type_name))); $node = node_load($nid, TRUE); $node_file = file_load($node->{$field_name}[Language::LANGCODE_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(); @@ -58,14 +58,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 and publish')); - $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::LANGCODE_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 multiple value field.'); } /** @@ -94,13 +94,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::LANGCODE_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->getSize()), '%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->getSize()), '%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->getSize()), '%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->getSize()), '%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->getSize()), '%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->getSize()), '%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->getSize()), '%maxsize' => $max_filesize))); } // Turn off the max filesize. @@ -110,8 +110,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::LANGCODE_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->getSize())))); - $this->assertFileEntryExists($node_file, t('File entry exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->getSize())))); + $this->assertFileExists($node_file, format_string('File exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->getSize())))); + $this->assertFileEntryExists($node_file, format_string('File entry exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->getSize())))); } /** @@ -132,8 +132,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::LANGCODE_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')); @@ -141,7 +141,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")); @@ -150,8 +150,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::LANGCODE_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.'); } } diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php index 702c8a2..6a097c6 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php @@ -47,16 +47,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::LANGCODE_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->getFileUri())); - $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) { @@ -70,8 +70,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::LANGCODE_NOT_SPECIFIED . "-0-upload']"); $this->assertTrue(isset($label[0]), 'Label for upload found.'); @@ -79,7 +79,7 @@ function testSingleValuedWidget() { // Save the node and ensure it does not have the file. $this->drupalPost(NULL, array(), t('Save and keep published')); $node = node_load($nid, TRUE); - $this->assertTrue(empty($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']), t('File was successfully removed from the node.')); + $this->assertTrue(empty($node->{$field_name}[Language::LANGCODE_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::LANGCODE_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 and publish')); @@ -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::LANGCODE_NOT_SPECIFIED][0]['fid']), t('Node was successfully saved without any files.')); + $this->assertTrue(empty($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']), 'Node was successfully saved without any files.'); } } @@ -217,21 +217,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::LANGCODE_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->getFileUri())); - $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/$instance->id/field"); - $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(); $this->drupalGet("admin/structure/types/manage/$type_name/fields/$instance->id/field"); - $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 = $comment->{'field_' . $name}->entity; - $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->getFileUri()); - $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->getFileUri())); - $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->getFileUri())); - $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); @@ -307,7 +307,7 @@ function testPrivateFileComment() { // Ensures normal user can no longer download the file. $this->drupalLogin($user); $this->drupalGet(file_create_url($comment_file->getFileUri())); - $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 6fb65e4..bf57606 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileManagedFileElementTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileManagedFileElementTest.php @@ -42,19 +42,19 @@ function testManagedFile() { // Submit without a file. $this->drupalPost($path, array(), t('Save')); - $this->assertRaw(t('The file ids are %fids.', array('%fids' => implode(',', array()))), t('Submitted without a file.')); + $this->assertRaw(t('The file ids are %fids.', array('%fids' => implode(',', array()))), 'Submitted without a file.'); // Submit a new file, without using the Upload button. $last_fid_prior = $this->getLastFileId(); $edit = array($file_field_name => drupal_realpath($test_file->getFileUri())); $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 ids are %fids.', array('%fids' => implode(',', array($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 ids are %fids.', array('%fids' => implode(',', array($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 ids are %fids.', array('%fids' => implode(',', array($last_fid)))), t('Empty submission did not change an existing file.')); + $this->assertRaw(t('The file ids are %fids.', array('%fids' => implode(',', array($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) { @@ -69,9 +69,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 ids are %fids.', array('%fids' => implode(',', array($last_fid)))), t('Submit handler has correct file info.')); + $this->assertRaw(t('The file ids are %fids.', array('%fids' => implode(',', array($last_fid)))), 'Submit handler has correct file info.'); // Remove, then Submit. $remove_button_title = $multiple ? t('Remove selected') : t('Remove'); @@ -88,7 +88,7 @@ function testManagedFile() { $this->drupalPost(NULL, $remove_edit, $remove_button_title); } $this->drupalPost(NULL, array(), t('Save')); - $this->assertRaw(t('The file ids are %fids.', array('%fids' => '')), t('Submission after file removal was successful.')); + $this->assertRaw(t('The file ids are %fids.', array('%fids' => '')), 'Submission after file removal was successful.'); // Upload, then Remove, then Submit. $this->drupalGet($path); @@ -112,7 +112,7 @@ function testManagedFile() { } $this->drupalPost(NULL, array(), t('Save')); - $this->assertRaw(t('The file ids are %fids.', array('%fids' => '')), t('Submission after file upload and removal was successful.')); + $this->assertRaw(t('The file ids are %fids.', array('%fids' => '')), 'Submission after file upload and removal was successful.'); } } } @@ -137,7 +137,7 @@ function testManagedFile() { // Save the entire form. $this->drupalPost(NULL, array(), t('Save')); - $this->assertRaw(t('The file ids are %fids.', array('%fids' => implode(',', $fid_list))), t('Two files saved into a single multiple file element.')); + $this->assertRaw(t('The file ids are %fids.', array('%fids' => implode(',', $fid_list))), 'Two files saved into a single multiple file element.'); // Delete only the first file. $edit = array( diff --git a/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php b/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php index 51cc239..96305bd 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 b509b07..b541953 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php @@ -53,10 +53,10 @@ function testPrivateFile() { $node_file = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']); // Ensure the file can be downloaded. $this->drupalGet(file_create_url($node_file->getFileUri())); - $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->getFileUri())); - $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); @@ -65,6 +65,6 @@ function testPrivateFile() { $node_file = file_load($node->{$no_access_field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']); // Ensure the file cannot be downloaded. $this->drupalGet(file_create_url($node_file->getFileUri())); - $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 b7d3e9f..9787554 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php @@ -63,11 +63,11 @@ function testFileTokenReplacement() { $tests['[file:owner:uid]'] = $file->getOwner()->id(); // 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_service->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. @@ -78,7 +78,7 @@ function testFileTokenReplacement() { foreach ($tests as $input => $expected) { $output = $token_service->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 7a7f9c1..57013de 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->id()); $this->assertFileHookCalled('load'); - $this->assertTrue(is_object($by_fid_file), t('file_load() returned an object.')); - $this->assertEqual($by_fid_file->id(), $file->id(), t("Loading by fid got the same fid."), 'File'); - $this->assertEqual($by_fid_file->getFileUri(), $file->getFileUri(), t("Loading by fid got the correct filepath."), 'File'); - $this->assertEqual($by_fid_file->getFilename(), $file->getFilename(), t("Loading by fid got the correct filename."), 'File'); - $this->assertEqual($by_fid_file->getMimeType(), $file->getMimeType(), t("Loading by fid got the correct MIME type."), 'File'); - $this->assertEqual($by_fid_file->isPermanent(), $file->isPermanent(), 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->id(), $file->id(), 'Loading by fid got the same fid.', 'File'); + $this->assertEqual($by_fid_file->getFileUri(), $file->getFileUri(), 'Loading by fid got the correct filepath.', 'File'); + $this->assertEqual($by_fid_file->getFilename(), $file->getFilename(), 'Loading by fid got the correct filename.', 'File'); + $this->assertEqual($by_fid_file->getMimeType(), $file->getMimeType(), 'Loading by fid got the correct MIME type.', 'File'); + $this->assertEqual($by_fid_file->isPermanent(), $file->isPermanent(), '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->getFileUri())); $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->id(), $file->id(), 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->id(), $file->id(), 'Loading by filepath got the correct fid.', 'File'); // Load by fid. file_test_reset(); $by_fid_files = file_load_multiple(array($file->id())); $this->assertFileHooksCalled(array()); - $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->getFileUri(), $file->getFileUri(), 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->getFileUri(), $file->getFileUri(), '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 5014fec..bf43322 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->getFileUri())); - $this->assertEqual($contents, file_get_contents($result->getFileUri()), t('Contents of file correctly written.')); + $this->assertEqual($contents, file_get_contents($result->getFileUri()), '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->id(), $result->id(), t("Source file id's' %fid is unchanged after move.", array('%fid' => $source->id()))); + $this->assertEqual($source->id(), $result->id(), "Source file id's' %fid is unchanged after move.", array('%fid' => $source->id())); // Reload the file from the database and check that the changes were // actually saved. $loaded_file = file_load($result->id(), 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->getFileUri(), 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->getFileUri())); - $this->assertEqual($contents, file_get_contents($result->getFileUri()), t('Contents of file correctly written.')); + $this->assertEqual($contents, file_get_contents($result->getFileUri()), '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->id(), TRUE); - $this->assertEqual($loaded_source->id(), $result->id(), t("Returned file's id matches the source.")); - $this->assertNotEqual($loaded_source->getFileUri(), $source->getFileUri(), t("Returned file path has changed from the original.")); + $this->assertEqual($loaded_source->id(), $result->id(), "Returned file's id matches the source."); + $this->assertNotEqual($loaded_source->getFileUri(), $source->getFileUri(), 'Returned file path has changed from the original.'); } /** @@ -99,9 +99,9 @@ function testExistingReplace() { $result = file_move(clone $source, $target->getFileUri(), FILE_EXISTS_REPLACE); // Look at the results. - $this->assertEqual($contents, file_get_contents($result->getFileUri()), t('Contents of file were overwritten.')); + $this->assertEqual($contents, file_get_contents($result->getFileUri()), 'Contents of file were overwritten.'); $this->assertFalse(file_exists($source->getFileUri())); - $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->getFileUri(), FILE_EXISTS_REPLACE); - $this->assertFalse($result, t('File move failed.')); - $this->assertEqual($contents, file_get_contents($source->getFileUri()), t('Contents of file were not altered.')); + $this->assertFalse($result, 'File move failed.'); + $this->assertEqual($contents, file_get_contents($source->getFileUri()), '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->getFileUri(), 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->getFileUri())); - $this->assertEqual($contents, file_get_contents($target->getFileUri()), t('Contents of file were not altered.')); + $this->assertEqual($contents, file_get_contents($target->getFileUri()), '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 cc91598..5579baf 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->getFileUri()), t("File was placed in Drupal's files directory.")); - $this->assertEqual($result->getFilename(), drupal_basename($result->getFileUri()), t("Filename was set to the file's basename.")); - $this->assertEqual($contents, file_get_contents($result->getFileUri()), t('Contents of the file are correct.')); - $this->assertEqual($result->getMimeType(), 'application/octet-stream', t('A MIME type was set.')); - $this->assertTrue($result->isPermanent(), t("The file's status was set to permanent.")); + $this->assertEqual(file_default_scheme(), file_uri_scheme($result->getFileUri()), "File was placed in Drupal's files directory."); + $this->assertEqual($result->getFilename(), drupal_basename($result->getFileUri()), "Filename was set to the file's basename."); + $this->assertEqual($contents, file_get_contents($result->getFileUri()), 'Contents of the file are correct.'); + $this->assertEqual($result->getMimeType(), 'application/octet-stream', 'A MIME type was set.'); + $this->assertTrue($result->isPermanent(), "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->getFileUri()), t("File was placed in Drupal's files directory.")); - $this->assertEqual($filename, drupal_basename($result->getFileUri()), t('File was named correctly.')); - $this->assertEqual($contents, file_get_contents($result->getFileUri()), t('Contents of the file are correct.')); - $this->assertEqual($result->getMimeType(), 'text/plain', t('A MIME type was set.')); - $this->assertTrue($result->isPermanent(), t("The file's status was set to permanent.")); + $this->assertEqual('public', file_uri_scheme($result->getFileUri()), "File was placed in Drupal's files directory."); + $this->assertEqual($filename, drupal_basename($result->getFileUri()), 'File was named correctly.'); + $this->assertEqual($contents, file_get_contents($result->getFileUri()), 'Contents of the file are correct.'); + $this->assertEqual($result->getMimeType(), 'text/plain', 'A MIME type was set.'); + $this->assertTrue($result->isPermanent(), "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->getFileUri(), FILE_EXISTS_RENAME); - $this->assertTrue($result, t("File saved successfully.")); + $this->assertTrue($result, 'File saved successfully.'); - $this->assertEqual('public', file_uri_scheme($result->getFileUri()), t("File was placed in Drupal's files directory.")); - $this->assertEqual($result->getFilename(), $existing->getFilename(), t("Filename was set to the basename of the source, rather than that of the renamed file.")); - $this->assertEqual($contents, file_get_contents($result->getFileUri()), t("Contents of the file are correct.")); - $this->assertEqual($result->getMimeType(), 'application/octet-stream', t("A MIME type was set.")); - $this->assertTrue($result->isPermanent(), t("The file's status was set to permanent.")); + $this->assertEqual('public', file_uri_scheme($result->getFileUri()), "File was placed in Drupal's files directory."); + $this->assertEqual($result->getFilename(), $existing->getFilename(), 'Filename was set to the basename of the source, rather than that of the renamed file.'); + $this->assertEqual($contents, file_get_contents($result->getFileUri()), 'Contents of the file are correct.'); + $this->assertEqual($result->getMimeType(), 'application/octet-stream', 'A MIME type was set.'); + $this->assertTrue($result->isPermanent(), "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->getFileUri(), FILE_EXISTS_REPLACE); - $this->assertTrue($result, t('File saved successfully.')); + $this->assertTrue($result, 'File saved successfully.'); - $this->assertEqual('public', file_uri_scheme($result->getFileUri()), t("File was placed in Drupal's files directory.")); - $this->assertEqual($result->getFilename(), $existing->getFilename(), t('Filename was set to the basename of the existing file, rather than preserving the original name.')); - $this->assertEqual($contents, file_get_contents($result->getFileUri()), t('Contents of the file are correct.')); - $this->assertEqual($result->getMimeType(), 'application/octet-stream', t('A MIME type was set.')); - $this->assertTrue($result->isPermanent(), t("The file's status was set to permanent.")); + $this->assertEqual('public', file_uri_scheme($result->getFileUri()), "File was placed in Drupal's files directory."); + $this->assertEqual($result->getFilename(), $existing->getFilename(), 'Filename was set to the basename of the existing file, rather than preserving the original name.'); + $this->assertEqual($contents, file_get_contents($result->getFileUri()), 'Contents of the file are correct.'); + $this->assertEqual($result->getMimeType(), 'application/octet-stream', 'A MIME type was set.'); + $this->assertTrue($result->isPermanent(), "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->getFileUri(), FILE_EXISTS_ERROR); - $this->assertFalse($result, t('Overwriting a file fails when FILE_EXISTS_ERROR is specified.')); - $this->assertEqual($contents, file_get_contents($existing->getFileUri()), 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->getFileUri()), '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 1161421..06405cd 100644 --- a/core/modules/file/lib/Drupal/file/Tests/SaveTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/SaveTest.php @@ -39,13 +39,13 @@ function testFileSave() { // Check that the correct hooks were called. $this->assertFileHooksCalled(array('insert')); - $this->assertTrue($file->id() > 0, t("A new file ID is set when saving a new file to the database."), 'File'); + $this->assertTrue($file->id() > 0, 'A new file ID is set when saving a new file to the database.', 'File'); $loaded_file = file_load($file->id()); - $this->assertNotNull($loaded_file, t("Record exists in the database.")); - $this->assertEqual($loaded_file->isPermanent(), $file->isPermanent(), t("Status was saved correctly.")); - $this->assertEqual($file->getSize(), filesize($file->getFileUri()), t("File size was set correctly."), 'File'); - $this->assertTrue($file->getChangedTime() > 1, t("File size was set correctly."), 'File'); - $this->assertEqual($loaded_file->langcode->value, Language::LANGCODE_NOT_SPECIFIED, t("Langcode was defaulted correctly.")); + $this->assertNotNull($loaded_file, 'Record exists in the database.'); + $this->assertEqual($loaded_file->isPermanent(), $file->isPermanent(), 'Status was saved correctly.'); + $this->assertEqual($file->getSize(), filesize($file->getFileUri()), 'File size was set correctly.', 'File'); + $this->assertTrue($file->getChangedTime() > 1, 'File size was set correctly.', 'File'); + $this->assertEqual($loaded_file->langcode->value, Language::LANGCODE_NOT_SPECIFIED, 'Langcode was defaulted correctly.'); // Resave the file, updating the existing record. file_test_reset(); @@ -56,12 +56,12 @@ function testFileSave() { // Check that the correct hooks were called. $this->assertFileHooksCalled(array('load', 'update')); - $this->assertEqual($file->id(), $file->id(), t("The file ID of an existing file is not changed when updating the database."), 'File'); - $this->assertTrue($file->getChangedTime() >= $file->getChangedTime(), t("Timestamp didn't go backwards."), 'File'); + $this->assertEqual($file->id(), $file->id(), 'The file ID of an existing file is not changed when updating the database.', 'File'); + $this->assertTrue($file->getChangedTime() >= $file->getChangedTime(), 'Timestamp didn't go backwards.', 'File'); $loaded_file = file_load($file->id()); - $this->assertNotNull($loaded_file, t("Record still exists in the database."), 'File'); - $this->assertEqual($loaded_file->isPermanent(), $file->isPermanent(), t("Status was saved correctly.")); - $this->assertEqual($loaded_file->langcode->value, 'en', t("Langcode was saved correctly.")); + $this->assertNotNull($loaded_file, 'Record still exists in the database.', 'File'); + $this->assertEqual($loaded_file->isPermanent(), $file->isPermanent(), 'Status was saved correctly.'); + $this->assertEqual($loaded_file->langcode->value, '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 6e9b359..b4a81a4 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->getFilename()); - $this->assertTrue(is_file($this->image->getFileUri()), t("The image file we're going to upload exists.")); + $this->assertTrue(is_file($this->image->getFileUri()), 'The image file we're 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->getFileUri()), ); $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->getMimeType(), 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->id(), $file2->id())); - $this->assertTrue(isset($files[$file1->id()]), t('File was loaded successfully')); - $this->assertTrue(isset($files[$file2->id()]), t('File was loaded successfully')); + $this->assertTrue(isset($files[$file1->id()]), 'File was loaded successfully'); + $this->assertTrue(isset($files[$file2->id()]), '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')); @@ -191,11 +191,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')); @@ -207,10 +207,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')); @@ -241,10 +241,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')); @@ -259,10 +259,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->getFilename())), 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->getFilename())), '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')); @@ -277,8 +277,8 @@ function testExistingRename() { 'files[file_test_upload]' => drupal_realpath($this->image->getFileUri()) ); $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')); @@ -293,8 +293,8 @@ function testExistingReplace() { 'files[file_test_upload]' => drupal_realpath($this->image->getFileUri()) ); $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')); @@ -309,8 +309,8 @@ function testExistingError() { 'files[file_test_upload]' => drupal_realpath($this->image->getFileUri()) ); $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()); @@ -321,6 +321,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 d76f9d8..17e51d8 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->id()) ->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->id()) ->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->id()) ->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->id()) ->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->id()) ->execute(); - $this->assertTrue(file_exists($temp_old->getFileUri()), t('Old temp file was created correctly.')); + $this->assertTrue(file_exists($temp_old->getFileUri()), '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->id()) ->execute(); - $this->assertTrue(file_exists($temp_new->getFileUri()), t('New temp file was created correctly.')); + $this->assertTrue(file_exists($temp_new->getFileUri()), '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->id()) ->execute(); - $this->assertTrue(file_exists($perm_old->getFileUri()), t('Old permanent file was created correctly.')); + $this->assertTrue(file_exists($perm_old->getFileUri()), '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->getFileUri()), t('New permanent file was created correctly.')); + $this->assertTrue(file_exists($perm_new->getFileUri()), '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->getFileUri()), t('Old temp file was correctly removed.')); - $this->assertTrue(file_exists($temp_new->getFileUri()), t('New temp file was correctly ignored.')); - $this->assertTrue(file_exists($perm_old->getFileUri()), t('Old permanent file was correctly ignored.')); - $this->assertTrue(file_exists($perm_new->getFileUri()), t('New permanent file was correctly ignored.')); + $this->assertFalse(file_exists($temp_old->getFileUri()), 'Old temp file was correctly removed.'); + $this->assertTrue(file_exists($temp_new->getFileUri()), 'New temp file was correctly ignored.'); + $this->assertTrue(file_exists($perm_old->getFileUri()), 'Old permanent file was correctly ignored.'); + $this->assertTrue(file_exists($perm_new->getFileUri()), '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 dc6c2ed..ad7f1c1 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->setFilename('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->getFileUri()), t('The image being tested exists.'), 'File'); + $this->assertTrue(file_exists($this->image->getFileUri()), '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->getFileUri()), t('The non-image being tested exists.'), 'File'); + $this->assertTrue(file_exists($this->non_image->getFileUri()), '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 ($this->container->has('image.toolkit')) { @@ -85,18 +85,18 @@ function testFileValidateImageResolution() { $this->image->setFileUri('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->getFileUri()); - $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->setFilename(str_repeat('x', 240)); $this->assertEqual(strlen($file->getFilename()), 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->setFilename(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->setFilename(''); $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);