1880
* Tests the file_scan_directory() function.
1882
class FileScanDirectory extends FileFieldTestCase {
1892
public static function getInfo() {
1894
'name' => 'File ScanDirectory',
1895
'description' => 'Tests the file_scan_directory() function.',
1906
$this->path = 'modules/file/tests/fixtures/file_scan_ignore';
1910
* Tests file_scan_directory() obeys 'file_scan_ignore_directories' setting.
1911
* If nomask is not passed as argument, it should use the default settings.
1912
* If nomask is passed as argument, it should obey this rule.
1914
public function testNoMask() {
1915
$files = file_scan_directory($this->path, '/\.txt$/');
1916
$this->assertEqual(3, count($files), '3 text files found when not ignoring directories.');
1919
$conf['file_scan_ignore_directories'] = array('frontend_framework');
1921
$files = file_scan_directory($this->path, '/\.txt$/');
1922
$this->assertEqual(1, count($files), '1 text files found when ignoring directories called "frontend_framework".');
1924
// Make that directories specified by default still work when a new nomask is provided.
1925
$files = file_scan_directory($this->path, '/\.txt$/', array('nomask' => '/^c.txt/'));
1926
$this->assertEqual(2, count($files), '2 text files found when an "nomask" option is passed in.');
1928
// Ensure that the directories in file_scan_ignore_directories are escaped using preg_quote.
1929
$conf['file_scan_ignore_directories'] = array('frontend.*');
1930
$files = file_scan_directory($this->path, '/\.txt$/');
1931
$this->assertEqual(3, count($files), '2 text files found when ignoring a directory that is not there.');