1 file.test FileScanDirectoryTest::testOptionNoMask()

Check that the no-mask parameter is honored.

File

core/modules/simpletest/tests/file.test, line 1325
This provides SimpleTests for the core file handling functionality. These include FileValidateTest and FileSaveTest.

Class

FileScanDirectoryTest
Tests the file_scan_directory() function.

Code

function testOptionNoMask() {
  // Grab a listing of all the JavaScript files.
  $all_files = file_scan_directory($this->path, '/^javascript-/', array('recurse' => FALSE));
  $this->assertEqual(2, count($all_files), 'Found two, expected javascript files.');

  // Set the nomask parameter be empty to include the .script file.
  $filtered_files = file_scan_directory($this->path, '/^javascript-/', array('nomask' => '/.script$/', 'recurse' => FALSE));
  $this->assertEqual(1, count($filtered_files), 'Filtered correctly.');

  // List all hidden files with the default nomask, and again with a custom
  // nomask that permits hidden files.
  $no_hidden_files = file_scan_directory($this->path, '/^\..*$/', array('recurse' => FALSE));
  $hidden_files = file_scan_directory($this->path, '/^\..*$/', array('nomask' => '/^$/', 'recurse' => FALSE));
  $this->assertEqual(0, count($no_hidden_files), 'Hidden files not included by default.');
  $this->assertEqual(1, count($hidden_files), 'Hidden files included when custom nomask used.');
}