From ceaf8a0c74e8c1dcd36235c1348725bc9109c91f Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 8 Nov 2008 21:49:47 +0000 Subject: - Patch #74645 by drewish, Robin Monks, tayknight: clean up file_scan_directory API to use regex. --- modules/simpletest/tests/file.test | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'modules/simpletest') diff --git a/modules/simpletest/tests/file.test b/modules/simpletest/tests/file.test index 564ecea35..e383defca 100644 --- a/modules/simpletest/tests/file.test +++ b/modules/simpletest/tests/file.test @@ -541,6 +541,38 @@ class FileDirectoryTest extends FileTestCase { } +/** + * Tests the file_scan_directory() function. + */ +class FileScanDirectoryTest extends FileTestCase { + /** + * Implementation of getInfo(). + */ + function getInfo() { + return array( + 'name' => t('File scan directory'), + 'description' => t('Tests the file_scan_directory() function.'), + 'group' => t('File'), + ); + } + + /** + * Check that the no-mask parameter is honored. + */ + function testNoMask() { + $path = $this->original_file_directory . '/simpletest'; + + // Grab a listing of all the JS files. + $all_files = file_scan_directory($path, '/javascript*/'); + $this->assertEqual(2, count($all_files), t('Found two, expected javascript files.')); + + // Now use the nomask parameter to filter out the .script file. + $filtered_files = file_scan_directory($path, '/javascript*/', '/.script$/'); + $this->assertEqual(1, count($filtered_files), t('Filtered correctly.')); + } +} + + /** * Deletion related tests. */ -- cgit v1.2.3