diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-02-22 17:55:30 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-02-22 17:55:30 +0000 |
commit | 5d658d08481c22b5ef577b39a29cd647438b211f (patch) | |
tree | 74fca69f981d985604b126943aed71bb79d1bbcb /modules/simpletest | |
parent | b3e36d655c831c63c26a710eb3c8bd82ca3b6fc5 (diff) | |
download | brdo-5d658d08481c22b5ef577b39a29cd647438b211f.tar.gz brdo-5d658d08481c22b5ef577b39a29cd647438b211f.tar.bz2 |
- Patch #380064 by c960657: make file_scan_directory() use save property names as file_load().
Diffstat (limited to 'modules/simpletest')
-rw-r--r-- | modules/simpletest/drupal_web_test_case.php | 6 | ||||
-rw-r--r-- | modules/simpletest/simpletest.install | 2 | ||||
-rw-r--r-- | modules/simpletest/simpletest.module | 2 | ||||
-rw-r--r-- | modules/simpletest/tests/file.test | 36 |
4 files changed, 23 insertions, 23 deletions
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php index cd8b16216..062fb6531 100644 --- a/modules/simpletest/drupal_web_test_case.php +++ b/modules/simpletest/drupal_web_test_case.php @@ -593,9 +593,9 @@ class DrupalWebTestCase { // If size is set then remove any files that are not of that size. if ($size !== NULL) { foreach ($files as $file) { - $stats = stat($file->filename); + $stats = stat($file->filepath); if ($stats['size'] != $size) { - unset($files[$file->filename]); + unset($files[$file->filepath]); } } } @@ -609,7 +609,7 @@ class DrupalWebTestCase { */ protected function drupalCompareFiles($file1, $file2) { // Determine which file is larger. - $compare_size = (filesize($file1->filename) > filesize($file2->filename)); + $compare_size = (filesize($file1->filepath) > filesize($file2->filepath)); if (!$compare_size) { // Both files were the same size, so return whichever one is alphabetically greater. return strnatcmp($file1->name, $file2->name); diff --git a/modules/simpletest/simpletest.install b/modules/simpletest/simpletest.install index 2aa13e926..94a8d6960 100644 --- a/modules/simpletest/simpletest.install +++ b/modules/simpletest/simpletest.install @@ -33,7 +33,7 @@ function simpletest_install() { $original = drupal_get_path('module', 'simpletest') . '/files'; $files = file_scan_directory($original, '/(html|image|javascript|php|sql)-.*/'); foreach ($files as $file) { - file_unmanaged_copy($file->filename, $path . '/' . $file->basename); + file_unmanaged_copy($file->filepath, $path); } $generated = TRUE; } diff --git a/modules/simpletest/simpletest.module b/modules/simpletest/simpletest.module index fe3127758..f0ab28fd7 100644 --- a/modules/simpletest/simpletest.module +++ b/modules/simpletest/simpletest.module @@ -465,7 +465,7 @@ function simpletest_get_all_tests() { $tests_directory = $module_path . '/tests'; if (is_dir($tests_directory)) { foreach (file_scan_directory($tests_directory, '/\.test$/') as $file) { - $files[] = $file->filename; + $files[] = $file->filepath; } } } diff --git a/modules/simpletest/tests/file.test b/modules/simpletest/tests/file.test index 2935bfd18..09a75b78e 100644 --- a/modules/simpletest/tests/file.test +++ b/modules/simpletest/tests/file.test @@ -21,14 +21,14 @@ function file_test_validator($file, $errors) { * When the function is called with $reset parameter TRUE the cache is cleared * and the results returned. * - * @param $file - * File object + * @param $filepath + * File path * @param $reset * Boolean indicating that the stored files should be removed and returned. * @return * An array of all previous $file parameters since $reset was last called. */ -function file_test_file_scan_callback($file, $reset = FALSE) { +function file_test_file_scan_callback($filepath, $reset = FALSE) { static $files = array(); if ($reset) { @@ -37,7 +37,7 @@ function file_test_file_scan_callback($file, $reset = FALSE) { return $ret; } - $files[] = $file; + $files[] = $filepath; } /** @@ -525,14 +525,14 @@ class FileSaveUploadTest extends FileHookTestCase { $this->drupalLogin($account); $this->image = current($this->drupalGetTestFiles('image')); - $this->assertTrue(is_file($this->image->filename), t("The file we're going to upload exists.")); + $this->assertTrue(is_file($this->image->filepath), t("The file we're going to upload exists.")); $this->maxFidBefore = db_query('SELECT MAX(fid) AS fid FROM {files}')->fetchField(); // Upload with replace to gurantee there's something there. $edit = array( 'file_test_replace' => FILE_EXISTS_REPLACE, - 'files[file_test_upload]' => realpath($this->image->filename) + 'files[file_test_upload]' => realpath($this->image->filepath) ); $this->drupalPost('file-test/upload', $edit, t('Submit')); $this->assertResponse(200, t('Received a 200 response for posted test file.')); @@ -559,7 +559,7 @@ class FileSaveUploadTest extends FileHookTestCase { // Upload a second file. $max_fid_before = db_query('SELECT MAX(fid) AS fid FROM {files}')->fetchField(); $image2 = current($this->drupalGetTestFiles('image')); - $edit = array('files[file_test_upload]' => realpath($image2->filename)); + $edit = array('files[file_test_upload]' => realpath($image2->filepath)); $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!')); @@ -584,7 +584,7 @@ class FileSaveUploadTest extends FileHookTestCase { function testExistingRename() { $edit = array( 'file_test_replace' => FILE_EXISTS_RENAME, - 'files[file_test_upload]' => realpath($this->image->filename) + 'files[file_test_upload]' => realpath($this->image->filepath) ); $this->drupalPost('file-test/upload', $edit, t('Submit')); $this->assertResponse(200, t('Received a 200 response for posted test file.')); @@ -600,7 +600,7 @@ class FileSaveUploadTest extends FileHookTestCase { function testExistingReplace() { $edit = array( 'file_test_replace' => FILE_EXISTS_REPLACE, - 'files[file_test_upload]' => realpath($this->image->filename) + 'files[file_test_upload]' => realpath($this->image->filepath) ); $this->drupalPost('file-test/upload', $edit, t('Submit')); $this->assertResponse(200, t('Received a 200 response for posted test file.')); @@ -616,7 +616,7 @@ class FileSaveUploadTest extends FileHookTestCase { function testExistingError() { $edit = array( 'file_test_replace' => FILE_EXISTS_ERROR, - 'files[file_test_upload]' => realpath($this->image->filename) + 'files[file_test_upload]' => realpath($this->image->filepath) ); $this->drupalPost('file-test/upload', $edit, t('Submit')); $this->assertResponse(200, t('Received a 200 response for posted test file.')); @@ -829,16 +829,16 @@ class FileScanDirectoryTest extends FileTestCase { // Check the first file. $file = reset($all_files); - $this->assertEqual(key($all_files), $file->filename, t('Correct array key was used for the first returned file.')); - $this->assertEqual($file->filename, $this->path . '/javascript-1.txt', t('First file name was set correctly.')); - $this->assertEqual($file->basename, 'javascript-1.txt', t('First basename was set correctly')); + $this->assertEqual(key($all_files), $file->filepath, t('Correct array key was used for the first returned file.')); + $this->assertEqual($file->filepath, $this->path . '/javascript-1.txt', t('First file name was set correctly.')); + $this->assertEqual($file->filename, 'javascript-1.txt', t('First basename was set correctly')); $this->assertEqual($file->name, 'javascript-1', t('First name was set correctly.')); // Check the second file. $file = next($all_files); - $this->assertEqual(key($all_files), $file->filename, t('Correct array key was used for the second returned file.')); - $this->assertEqual($file->filename, $this->path . '/javascript-2.script', t('Second file name was set correctly.')); - $this->assertEqual($file->basename, 'javascript-2.script', t('Second basename was set correctly')); + $this->assertEqual(key($all_files), $file->filepath, t('Correct array key was used for the second returned file.')); + $this->assertEqual($file->filepath, $this->path . '/javascript-2.script', t('Second file name was set correctly.')); + $this->assertEqual($file->filename, 'javascript-2.script', t('Second basename was set correctly')); $this->assertEqual($file->name, 'javascript-2', t('Second name was set correctly.')); } @@ -879,13 +879,13 @@ class FileScanDirectoryTest extends FileTestCase { function testOptionKey() { // "filename", for the path starting with $dir. $expected = array($this->path . '/javascript-1.txt', $this->path . '/javascript-2.script'); - $actual = array_keys(file_scan_directory($this->path, '/^javascript-/', array('key' => 'filename'))); + $actual = array_keys(file_scan_directory($this->path, '/^javascript-/', array('key' => 'filepath'))); sort($actual); $this->assertEqual($expected, $actual, t('Returned the correct values for the filename key.')); // "basename", for the basename of the file. $expected = array('javascript-1.txt', 'javascript-2.script'); - $actual = array_keys(file_scan_directory($this->path, '/^javascript-/', array('key' => 'basename'))); + $actual = array_keys(file_scan_directory($this->path, '/^javascript-/', array('key' => 'filename'))); sort($actual); $this->assertEqual($expected, $actual, t('Returned the correct values for the basename key.')); |