function ScanDirectoryTest::testOptionCallback in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/File/ScanDirectoryTest.php \Drupal\system\Tests\File\ScanDirectoryTest::testOptionCallback()
Check that the callback function is called correctly.
File
- core/
modules/ system/ src/ Tests/ File/ ScanDirectoryTest.php, line 66 - Contains \Drupal\system\Tests\File\ScanDirectoryTest.
Class
- ScanDirectoryTest
- Tests the file_scan_directory() function.
Namespace
Drupal\system\Tests\FileCode
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), 'No files were found.');
$results = file_test_file_scan_callback();
file_test_file_scan_callback_reset();
$this
->assertEqual(0, count($results), 'No files were passed to the callback.');
// Grab a listing of all the JavaScript 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), 'Found two, expected javascript files.');
$results = file_test_file_scan_callback();
file_test_file_scan_callback_reset();
$this
->assertEqual(2, count($results), 'Files were passed to the callback.');
}