function ScanDirectoryTest::testIgnoreDirectories
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/File/ScanDirectoryTest.php \Drupal\KernelTests\Core\File\ScanDirectoryTest::testIgnoreDirectories()
- 8.9.x core/tests/Drupal/KernelTests/Core/File/ScanDirectoryTest.php \Drupal\KernelTests\Core\File\ScanDirectoryTest::testIgnoreDirectories()
- 11.x core/tests/Drupal/KernelTests/Core/File/ScanDirectoryTest.php \Drupal\KernelTests\Core\File\ScanDirectoryTest::testIgnoreDirectories()
Tests ::scanDirectory obeys 'file_scan_ignore_directories' setting.
@covers ::scanDirectory
File
-
core/
tests/ Drupal/ KernelTests/ Core/ File/ ScanDirectoryTest.php, line 173
Class
- ScanDirectoryTest
- Tests \Drupal\Core\File\FileSystem::scanDirectory.
Namespace
Drupal\KernelTests\Core\FileCode
public function testIgnoreDirectories() : void {
$files = $this->fileSystem
->scanDirectory('core/modules/system/tests/fixtures/IgnoreDirectories', '/\\.txt$/');
$this->assertCount(2, $files, '2 text files found when not ignoring directories.');
$this->setSetting('file_scan_ignore_directories', [
'frontend_framework',
]);
$files = $this->fileSystem
->scanDirectory('core/modules/system/tests/fixtures/IgnoreDirectories', '/\\.txt$/');
$this->assertCount(1, $files, '1 text files found when ignoring directories called "frontend_framework".');
// Ensure that the directories in file_scan_ignore_directories are escaped
// using preg_quote.
$this->setSetting('file_scan_ignore_directories', [
'frontend.*',
]);
$files = $this->fileSystem
->scanDirectory('core/modules/system/tests/fixtures/IgnoreDirectories', '/\\.txt$/');
$this->assertCount(2, $files, '2 text files found when ignoring a directory that is not there.');
$files = $this->fileSystem
->scanDirectory('core/modules/system/tests/fixtures/IgnoreDirectories', '/\\.txt$/', [
'nomask' => '/^something_thing_else$/',
]);
$this->assertCount(2, $files, '2 text files found when an "nomask" option is passed in.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.