summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/simpletest/drupal_web_test_case.php14
-rw-r--r--modules/upload/upload.test7
2 files changed, 13 insertions, 8 deletions
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
index 35042ad2c..eba232b86 100644
--- a/modules/simpletest/drupal_web_test_case.php
+++ b/modules/simpletest/drupal_web_test_case.php
@@ -486,13 +486,19 @@ class DrupalWebTestCase {
}
/**
- * Compare two files based on size.
+ * Compare two files based on size and file name.
*/
function drupalCompareFiles($file1, $file2) {
- if (stat($file1->filename) > stat($file2->filename)) {
- return 1;
+ // Determine which file is larger.
+ $compare_size = (filesize($file1->filename) > filesize($file2->filename));
+ if (!$compare_size) {
+ // Both files were the same size, so return whichever one is alphabetically greater.
+ return strnatcmp($file1->name, $file2->name);
+ }
+ else {
+ // Return TRUE if $file1 is larger than $file2.
+ return $compare_size;
}
- return -1;
}
/**
diff --git a/modules/upload/upload.test b/modules/upload/upload.test
index 1b1400021..a1f05757e 100644
--- a/modules/upload/upload.test
+++ b/modules/upload/upload.test
@@ -102,14 +102,13 @@ class UploadTestCase extends DrupalWebTestCase {
$node = $this->drupalCreateNode();
// Attempt to upload .txt file when .html is only extension allowed.
- $text_files = array_values($this->drupalGetTestFiles('text'));
+ $text_file = current($this->drupalGetTestFiles('text'));
// Select a file that's less than the 1MB upload limit so we only test one
// limit at a time.
- $text_file = $text_files[2]->filename;
- $this->uploadFile($node, $text_file, FALSE);
+ $this->uploadFile($node, $text_file->filename, FALSE);
// Test the error message in two steps in case there are additional errors
// that change the error message's format.
- $this->assertRaw(t('The specified file %name could not be uploaded.', array('%name' => basename($text_file))), t('File %filename was not allowed to be uploaded', array('%filename' => $text_file)));
+ $this->assertRaw(t('The specified file %name could not be uploaded.', array('%name' => $text_file->basename)), t('File %filename was not allowed to be uploaded', array('%filename' => $text_file->filename)));
$this->assertRaw(t('Only files with the following extensions are allowed: %files-allowed.', array('%files-allowed' => $settings['upload_extensions'])), t('File extension cited as reason for failure'));
// Attempt to upload .html file when .html is only extension allowed.