function ScanDirectoryTest::testOptionRecurse

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

Check that the recurse option descends into subdirectories.

@covers ::scanDirectory

File

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

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 testOptionRecurse() : void {
    $files = $this->fileSystem
        ->scanDirectory($this->path . '/..', '/^javascript-/', [
        'recurse' => FALSE,
    ]);
    $this->assertEmpty($files, "Without recursion couldn't find javascript files.");
    $files = $this->fileSystem
        ->scanDirectory($this->path . '/..', '/^javascript-/', [
        'recurse' => TRUE,
    ]);
    $this->assertCount(2, $files, 'With recursion we found the expected javascript files.');
}

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