function ScanDirectoryTest::testOptionNoMask

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/File/ScanDirectoryTest.php \Drupal\KernelTests\Core\File\ScanDirectoryTest::testOptionNoMask()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/File/ScanDirectoryTest.php \Drupal\KernelTests\Core\File\ScanDirectoryTest::testOptionNoMask()
  3. 10 core/tests/Drupal/KernelTests/Core/File/ScanDirectoryTest.php \Drupal\KernelTests\Core\File\ScanDirectoryTest::testOptionNoMask()

Check that the no-mask parameter is honored.

@covers ::scanDirectory

File

core/tests/Drupal/KernelTests/Core/File/ScanDirectoryTest.php, line 103

Class

ScanDirectoryTest
Tests <a href="/api/drupal/core%21lib%21Drupal%21Core%21File%21FileSystem.php/class/FileSystem/11.x" title="Provides helpers to operate on files and stream wrappers." class="local">\Drupal\Core\File\FileSystem</a>::scanDirectory.

Namespace

Drupal\KernelTests\Core\File

Code

public function testOptionNoMask() : void {
    // Grab a listing of all the JavaScript files.
    $all_files = $this->fileSystem
        ->scanDirectory($this->path, '/^javascript-/');
    $this->assertCount(2, $all_files, 'Found two, expected javascript files.');
    // Now use the nomask parameter to filter out the .script file.
    $filtered_files = $this->fileSystem
        ->scanDirectory($this->path, '/^javascript-/', [
        'nomask' => '/.script$/',
    ]);
    $this->assertCount(1, $filtered_files, 'Filtered correctly.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.