summaryrefslogtreecommitdiff
path: root/modules/file
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-08-05 23:53:39 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-08-05 23:53:39 +0000
commit25171a17f626695ecf984cc44b60d3eae1310b4c (patch)
tree3268ef89294cbb96d0875d665012c4ff16d8c68a /modules/file
parentcacd044a6398df92de68c5aea31987ac0fff507a (diff)
downloadbrdo-25171a17f626695ecf984cc44b60d3eae1310b4c.tar.gz
brdo-25171a17f626695ecf984cc44b60d3eae1310b4c.tar.bz2
Reverting #500866. Needs more discussion.
Diffstat (limited to 'modules/file')
-rw-r--r--modules/file/tests/file.test118
1 files changed, 59 insertions, 59 deletions
diff --git a/modules/file/tests/file.test b/modules/file/tests/file.test
index f025d0529..2bf5b7f86 100644
--- a/modules/file/tests/file.test
+++ b/modules/file/tests/file.test
@@ -244,15 +244,15 @@ class FileFieldWidgetTestCase extends FileFieldTestCase {
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
$node = node_load($nid, NULL, TRUE);
$node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0];
- $this->assertFileExists($node_file, 'New file saved to disk on node creation.');
+ $this->assertFileExists($node_file, t('New file saved to disk on node creation.'));
// Test file download.
$this->drupalGet(file_create_url($node_file->uri));
- $this->assertResponse(200, 'Confirmed that the generated URL is correct by downloading the shipped file.');
+ $this->assertResponse(200, t('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'), 'Node with file does not display the "Upload" button.');
- $this->assertFieldByXpath('//input[@type="submit"]', 'Remove', 'Node with file displays the "Remove" button.');
+ $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.'));
// "Click" the remove button (emulating either a nojs or js submission).
switch ($type) {
@@ -271,13 +271,13 @@ class FileFieldWidgetTestCase extends FileFieldTestCase {
}
// Ensure the page now has an upload button instead of a remove button.
- $this->assertNoFieldByXPath('//input[@type="submit"]', t('Remove'), 'After clicking the "Remove" button, it is no longer displayed.');
- $this->assertFieldByXpath('//input[@type="submit"]', 'Upload', 'After clicking the "Remove" button, the "Upload" button is displayed.');
+ $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.'));
// Save the node and ensure it does not have the file.
$this->drupalPost(NULL, array(), t('Save'));
$node = node_load($nid, NULL, TRUE);
- $this->assertTrue(empty($node->{$field_name}[LANGUAGE_NONE][0]['fid']), 'File was successfully removed from the node.');
+ $this->assertTrue(empty($node->{$field_name}[LANGUAGE_NONE][0]['fid']), t('File was successfully removed from the node.'));
}
// Test private download method.
@@ -288,18 +288,18 @@ class FileFieldWidgetTestCase extends FileFieldTestCase {
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
$node = node_load($nid, NULL, TRUE);
$node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0];
- $this->assertFileExists($node_file, 'New file saved to disk on node creation.');
+ $this->assertFileExists($node_file, t('New file saved to disk on node creation.'));
// Test file download.
$this->drupalGet(file_create_url($node_file->uri));
- $this->assertResponse(200, 'Confirmed that the generated URL is correct by downloading the shipped file.');
+ $this->assertResponse(200, t('Confirmed that the generated URL is correct by downloading the shipped file.'));
// Ensure we can't change 'uri_scheme' field settings while there are some
// entities with uploaded files.
$this->drupalGet("admin/structure/types/manage/$type_name/fields/$field_name");
- $this->assertFieldByXpath('//input[@id="edit-field-settings-uri-scheme-public" and @disabled="disabled"]', 'public', 'Upload destination setting disabled.');
+ $this->assertFieldByXpath('//input[@id="edit-field-settings-uri-scheme-public" and @disabled="disabled"]', 'public', t('Upload destination setting disabled.'));
// Delete node and confirm that setting could be changed.
node_delete($nid);
$this->drupalGet("admin/structure/types/manage/$type_name/fields/$field_name");
- $this->assertFieldByXpath('//input[@id="edit-field-settings-uri-scheme-public" and not(@disabled)]', 'public', 'Upload destination setting enabled.');
+ $this->assertFieldByXpath('//input[@id="edit-field-settings-uri-scheme-public" and not(@disabled)]', 'public', t('Upload destination setting enabled.'));
}
}
@@ -345,25 +345,25 @@ class FileFieldRevisionTestCase extends FileFieldTestCase {
$node = node_load($nid, NULL, TRUE);
$node_file_r1 = (object) $node->{$field_name}[LANGUAGE_NONE][0];
$node_vid_r1 = $node->vid;
- $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.');
+ $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.'));
// Upload another file to the same node in a new revision.
$this->replaceNodeFile($test_file, $field_name, $nid);
$node = node_load($nid, NULL, TRUE);
$node_file_r2 = (object) $node->{$field_name}[LANGUAGE_NONE][0];
$node_vid_r2 = $node->vid;
- $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.');
+ $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.'));
// Check that the original file is still in place on the first revision.
$node = node_load($nid, $node_vid_r1, TRUE);
- $this->assertEqual($node_file_r1, (object) $node->{$field_name}[LANGUAGE_NONE][0], '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.');
+ $this->assertEqual($node_file_r1, (object) $node->{$field_name}[LANGUAGE_NONE][0], 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.'));
// Save a new version of the node without any changes.
// Check that the file is still the same as the previous revision.
@@ -371,23 +371,23 @@ class FileFieldRevisionTestCase extends FileFieldTestCase {
$node = node_load($nid, NULL, TRUE);
$node_file_r3 = (object) $node->{$field_name}[LANGUAGE_NONE][0];
$node_vid_r3 = $node->vid;
- $this->assertEqual($node_file_r2, $node_file_r3, 'Previous revision file still in place after creating a new revision without a new file.');
- $this->assertFileIsPermanent($node_file_r3, 'New revision file is permanent.');
+ $this->assertEqual($node_file_r2, $node_file_r3, t('Previous revision file still in place after creating a new revision without a new file.'));
+ $this->assertFileIsPermanent($node_file_r3, t('New revision file is permanent.'));
// 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, NULL, TRUE);
$node_file_r4 = (object) $node->{$field_name}[LANGUAGE_NONE][0];
$node_vid_r4 = $node->vid;
- $this->assertEqual($node_file_r1, $node_file_r4, 'Original revision file still in place after reverting to the original revision.');
- $this->assertFileIsPermanent($node_file_r4, 'Original revision file still permanent after reverting to the original revision.');
+ $this->assertEqual($node_file_r1, $node_file_r4, t('Original revision file still in place after reverting to the original revision.'));
+ $this->assertFileIsPermanent($node_file_r4, t('Original revision file still permanent after reverting to the original revision.'));
// 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, '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.');
+ $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.'));
// Attach the second file to a user.
$user = $this->drupalCreateUser();
@@ -398,9 +398,9 @@ class FileFieldRevisionTestCase extends FileFieldTestCase {
// 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, '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.');
+ $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.'));
// Delete the user and check that the file is also deleted.
user_delete($user->uid);
@@ -408,13 +408,13 @@ class FileFieldRevisionTestCase extends FileFieldTestCase {
// not be necessary here. The file really is deleted, but stream wrappers
// doesn't seem to think so unless we clear the PHP file stat() cache.
clearstatcache();
- $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.');
+ $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.'));
// Delete the entire node and check that the original file is deleted.
$this->drupalPost('node/' . $nid . '/delete', array(), t('Delete'));
- $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.');
+ $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.'));
}
}
@@ -458,13 +458,13 @@ class FileFieldDisplayTestCase extends FileFieldTestCase {
$node = node_load($nid, NULL, TRUE);
$node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0];
$default_output = theme('file_link', array('file' => $node_file));
- $this->assertRaw($default_output, 'Default formatter displaying correctly on full node view.');
+ $this->assertRaw($default_output, t('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_NONE . '][0][display]' => FALSE);
$this->drupalPost('node/' . $nid . '/edit', $edit, t('Save'));
- $this->assertNoRaw($default_output, 'Field is hidden when "display" option is unchecked.');
+ $this->assertNoRaw($default_output, t('Field is hidden when "display" option is unchecked.'));
}
}
@@ -500,15 +500,15 @@ class FileFieldValidateTestCase extends FileFieldTestCase {
$langcode = LANGUAGE_NONE;
$edit = array("title" => $this->randomName());
$this->drupalPost('node/add/' . $type_name, $edit, t('Save'));
- $this->assertRaw(t('!title field is required.', array('!title' => $instance['label'])), 'Node save failed when required file field was empty.');
+ $this->assertRaw(t('!title field is required.', array('!title' => $instance['label'])), t('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);
$node = node_load($nid, NULL, TRUE);
$node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0];
- $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.');
+ $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.'));
// Try again with a multiple value field.
field_delete_field($field_name);
@@ -517,14 +517,14 @@ class FileFieldValidateTestCase extends FileFieldTestCase {
// Try to post a new node without uploading a file in the multivalue field.
$edit = array('title' => $this->randomName());
$this->drupalPost('node/add/' . $type_name, $edit, t('Save'));
- $this->assertRaw(t('!title field is required.', array('!title' => $instance['label'])), 'Node save failed when required multiple value file field was empty.');
+ $this->assertRaw(t('!title field is required.', array('!title' => $instance['label'])), t('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, NULL, TRUE);
$node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0];
- $this->assertFileExists($node_file, 'File exists after uploading to the required multiple value field.');
- $this->assertFileEntryExists($node_file, 'File entry exists after uploading to the required multipel value field.');
+ $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.'));
// Remove our file field.
field_delete_field($field_name);
@@ -559,13 +559,13 @@ class FileFieldValidateTestCase extends FileFieldTestCase {
$nid = $this->uploadNodeFile($small_file, $field_name, $type_name);
$node = node_load($nid, NULL, TRUE);
$node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0];
- $this->assertFileExists($node_file, 'File exists after uploading a file (' . format_size($small_file->filesize) . ') under the max limit (' . $max_filesize . ').');
- $this->assertFileEntryExists($node_file, 'File entry exists after uploading a file (' . format_size($small_file->filesize) . ') under the max limit (' . $max_filesize . ').');
+ $this->assertFileExists($node_file, t('File exists after uploading a file (%filesize) under the max limit (%maxsize).', array('%filesize' => format_size($small_file->filesize), '%maxsize' => $max_filesize)));
+ $this->assertFileEntryExists($node_file, t('File entry exists after uploading a file (%filesize) under the max limit (%maxsize).', array('%filesize' => format_size($small_file->filesize), '%maxsize' => $max_filesize)));
// Check that uploading the large file fails (1M limit).
$nid = $this->uploadNodeFile($large_file, $field_name, $type_name);
$error_message = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size($large_file->filesize), '%maxsize' => format_size($file_limit)));
- $this->assertRaw($error_message, 'Node save failed when file (' . format_size($large_file->filesize) . ') exceeded the max upload size (' . $max_filesize . ').');
+ $this->assertRaw($error_message, t('Node save failed when file (%filesize) exceeded the max upload size (%maxsize).', array('%filesize' => format_size($large_file->filesize), '%maxsize' => $max_filesize)));
}
// Turn off the max filesize.
@@ -575,8 +575,8 @@ class FileFieldValidateTestCase extends FileFieldTestCase {
$nid = $this->uploadNodeFile($large_file, $field_name, $type_name);
$node = node_load($nid, NULL, TRUE);
$node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0];
- $this->assertFileExists($node_file, 'File exists after uploading a file (' . format_size($large_file->filesize) . ') with no max limit.');
- $this->assertFileEntryExists($node_file, 'File entry exists after uploading a file (' . format_size($large_file->filesize) . ') with no max limit.');
+ $this->assertFileExists($node_file, t('File exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->filesize))));
+ $this->assertFileEntryExists($node_file, t('File entry exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->filesize))));
// Remove our file field.
field_delete_field($field_name);
@@ -602,8 +602,8 @@ class FileFieldValidateTestCase extends FileFieldTestCase {
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
$node = node_load($nid, NULL, TRUE);
$node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0];
- $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.');
+ $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.'));
// Enable extension checking for text files.
$this->updateFileField($field_name, $type_name, array('file_extensions' => 'txt'));
@@ -611,7 +611,7 @@ class FileFieldValidateTestCase extends FileFieldTestCase {
// 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, 'Node save failed when file uploaded with the wrong extension.');
+ $this->assertRaw($error_message, t('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"));
@@ -620,8 +620,8 @@ class FileFieldValidateTestCase extends FileFieldTestCase {
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
$node = node_load($nid, NULL, TRUE);
$node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0];
- $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.');
+ $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.'));
// Remove our file field.
field_delete_field($field_name);
@@ -655,7 +655,7 @@ class FileFieldPathTestCase extends FileFieldTestCase {
// Check that the file was uploaded to the file root.
$node = node_load($nid, NULL, TRUE);
$node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0];
- $this->assertPathMatch('public://' . $test_file->filename, $node_file->uri, 'The file ' . $node_file->uri . ' was uploaded to the correct path.');
+ $this->assertPathMatch('public://' . $test_file->filename, $node_file->uri, t('The file %file was uploaded to the correct path.', array('%file' => $node_file->uri)));
// Change the path to contain multiple subdirectories.
$field = $this->updateFileField($field_name, $type_name, array('file_directory' => 'foo/bar/baz'));
@@ -666,7 +666,7 @@ class FileFieldPathTestCase extends FileFieldTestCase {
// Check that the file was uploaded into the subdirectory.
$node = node_load($nid, NULL, TRUE);
$node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0];
- $this->assertPathMatch('public://foo/bar/baz/' . $test_file->filename, $node_file->uri, 'The file ' . $node_file->uri . ' was uploaded to the correct path.');
+ $this->assertPathMatch('public://foo/bar/baz/' . $test_file->filename, $node_file->uri, t('The file %file was uploaded to the correct path.', array('%file' => $node_file->uri)));
// Check the path when used with tokens.
// Change the path to contain multiple token directories.
@@ -680,7 +680,7 @@ class FileFieldPathTestCase extends FileFieldTestCase {
$node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0];
$data = array('user' => $this->admin_user);
$subdirectory = token_replace('[user:uid]/[user:name]', $data);
- $this->assertPathMatch('public://' . $subdirectory . '/' . $test_file->filename, $node_file->uri, 'The file ' . $node_file->uri . ' was uploaded to the correct path with token replacements.');
+ $this->assertPathMatch('public://' . $subdirectory . '/' . $test_file->filename, $node_file->uri, t('The file %file was uploaded to the correct path with token replacements.', array('%file' => $node_file->uri)));
}
/**
@@ -760,11 +760,11 @@ class FileTokenReplaceTestCase extends FileFieldTestCase {
$tests['[file:owner:uid]'] = $file->uid;
// Test to make sure that we generated something for each token.
- $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
+ $this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.'));
foreach ($tests as $input => $expected) {
$output = token_replace($input, array('file' => $file), array('language' => $language));
- $this->assertFalse(strcmp($output, $expected), 'Sanitized file token ' . $input . ' replaced.');
+ $this->assertFalse(strcmp($output, $expected), t('Sanitized file token %token replaced.', array('%token' => $input)));
}
// Generate and test unsanitized tokens.
@@ -776,7 +776,7 @@ class FileTokenReplaceTestCase extends FileFieldTestCase {
foreach ($tests as $input => $expected) {
$output = token_replace($input, array('file' => $file), array('language' => $language, 'sanitize' => FALSE));
- $this->assertFalse(strcmp($output, $expected), 'Unsanitized file token ' . $input . ' replaced.');
+ $this->assertFalse(strcmp($output, $expected), t('Unsanitized file token %token replaced.', array('%token' => $input)));
}
}
}