FilenameFilterIterator example

use Symfony\Component\Finder\Iterator\FilenameFilterIterator;

class FilenameFilterIteratorTest extends IteratorTestCase
{
    /** * @dataProvider getAcceptData */
    public function testAccept($matchPatterns$noMatchPatterns$expected)
    {
        $inner = new InnerNameIterator(['test.php', 'test.py', 'foo.php']);

        $iterator = new FilenameFilterIterator($inner$matchPatterns$noMatchPatterns);

        $this->assertIterator($expected$iterator);
    }

    public static function getAcceptData()
    {
        return [
            [['test.*'][]['test.php', 'test.py']],
            [[]['test.*']['foo.php']],
            [['*.php']['test.*']['foo.php']],
            [['*.php', '*.py']['foo.*']['test.php', 'test.py']],
            [[
$iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);

        if ($minDepth > 0 || $maxDepth < \PHP_INT_MAX) {
            $iterator = new Iterator\DepthRangeFilterIterator($iterator$minDepth$maxDepth);
        }

        if ($this->mode) {
            $iterator = new Iterator\FileTypeFilterIterator($iterator$this->mode);
        }

        if ($this->names || $this->notNames) {
            $iterator = new Iterator\FilenameFilterIterator($iterator$this->names, $this->notNames);
        }

        if ($this->contains || $this->notContains) {
            $iterator = new Iterator\FilecontentFilterIterator($iterator$this->contains, $this->notContains);
        }

        if ($this->sizes) {
            $iterator = new Iterator\SizeRangeFilterIterator($iterator$this->sizes);
        }

        if ($this->dates) {
            
Home | Imprint | This part of the site doesn't use cookies.