You are here

public function RegexDirectoryIteratorTest::testRegexDirectoryIterator in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Component/FileSystem/RegexDirectoryIteratorTest.php \Drupal\Tests\Component\FileSystem\RegexDirectoryIteratorTest::testRegexDirectoryIterator()
  2. 9 core/tests/Drupal/Tests/Component/FileSystem/RegexDirectoryIteratorTest.php \Drupal\Tests\Component\FileSystem\RegexDirectoryIteratorTest::testRegexDirectoryIterator()

@covers ::accept @dataProvider providerTestRegexDirectoryIterator

File

core/tests/Drupal/Tests/Component/FileSystem/RegexDirectoryIteratorTest.php, line 19

Class

RegexDirectoryIteratorTest
@coversDefaultClass \Drupal\Component\FileSystem\RegexDirectoryIterator @group FileSystem

Namespace

Drupal\Tests\Component\FileSystem

Code

public function testRegexDirectoryIterator(array $directory, $regex, array $expected) {
  vfsStream::setup('root', NULL, $directory);
  $iterator = new RegexDirectoryIterator(vfsStream::url('root'), $regex);

  // Create an array of filenames to assert against.
  $file_list = array_map(function (\SplFileInfo $file) {
    return $file
      ->getFilename();
  }, array_values(iterator_to_array($iterator)));
  $this
    ->assertSame($expected, $file_list);
}