FileScanDirectoryTest::testOptionCallback

7 file.test FileScanDirectoryTest::testOptionCallback()
8 file.test FileScanDirectoryTest::testOptionCallback()

Check that the callback function is called correctly.

File

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

Code

function testOptionCallback() {
  // When nothing is matched nothing should be passed to the callback.
  $all_files = file_scan_directory($this->path, '/^NONEXISTINGFILENAME/', array('callback' => 'file_test_file_scan_callback'));
  $this->assertEqual(0, count($all_files), t('No files were found.'));
  $results = file_test_file_scan_callback();
  file_test_file_scan_callback_reset();
  $this->assertEqual(0, count($results), t('No files were passed to the callback.'));

  // Grab a listing of all the JavaSscript files and check that they're
  // passed to the callback.
  $all_files = file_scan_directory($this->path, '/^javascript-/', array('callback' => 'file_test_file_scan_callback'));
  $this->assertEqual(2, count($all_files), t('Found two, expected javascript files.'));
  $results = file_test_file_scan_callback();
  file_test_file_scan_callback_reset();
  $this->assertEqual(2, count($results), t('Files were passed to the callback.'));
}
Login or register to post comments