function ScanDirectoryTest::testOptionMinDepth

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

Tests the min_depth option of scanDirectory().

@covers ::scanDirectory

File

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

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 testOptionMinDepth() : void {
    $files = $this->fileSystem
        ->scanDirectory($this->path, '/^javascript-/', [
        'min_depth' => 0,
    ]);
    $this->assertCount(2, $files, 'No minimum-depth gets files in current directory.');
    $files = $this->fileSystem
        ->scanDirectory($this->path, '/^javascript-/', [
        'min_depth' => 1,
    ]);
    $this->assertEmpty($files, 'Minimum-depth of 1 successfully excludes files from current directory.');
}

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