function RegexDirectoryIteratorTest::testRegexDirectoryIterator

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Component/FileSystem/RegexDirectoryIteratorTest.php \Drupal\Tests\Component\FileSystem\RegexDirectoryIteratorTest::testRegexDirectoryIterator()
  2. 10 core/tests/Drupal/Tests/Component/FileSystem/RegexDirectoryIteratorTest.php \Drupal\Tests\Component\FileSystem\RegexDirectoryIteratorTest::testRegexDirectoryIterator()
  3. 8.9.x 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[[api-linebreak]] @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);
}

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