Sha256: 991a16e066c64218778f1ff81bf33035b141d52754042d3f354a26e0c469a4fc

Contents?: true

Size: 1.82 KB

Versions: 16

Compression:

Stored size: 1.82 KB

Contents

<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Finder\Tests\Iterator;

use Symfony\Component\Finder\Iterator\FileTypeFilterIterator;

class FileTypeFilterIteratorTest extends RealIteratorTestCase
{
    /**
     * @dataProvider getAcceptData
     */
    public function testAccept($mode, $expected)
    {
        $inner = new InnerTypeIterator(self::$files);

        $iterator = new FileTypeFilterIterator($inner, $mode);

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

    public function getAcceptData()
    {
        $onlyFiles = [
            'test.py',
            'foo/bar.tmp',
            'test.php',
            '.bar',
            '.foo/.bar',
            '.foo/bar',
            'foo bar',
            'qux/baz_100_1.py',
            'qux/baz_1_2.py',
            'qux_0_1.php',
            'qux_1000_1.php',
            'qux_1002_0.php',
            'qux_10_2.php',
            'qux_12_0.php',
            'qux_2_0.php',
        ];

        $onlyDirectories = [
            '.git',
            'foo',
            'qux',
            'toto',
            'toto/.git',
            '.foo',
        ];

        return [
            [FileTypeFilterIterator::ONLY_FILES, $this->toAbsolute($onlyFiles)],
            [FileTypeFilterIterator::ONLY_DIRECTORIES, $this->toAbsolute($onlyDirectories)],
        ];
    }
}

class InnerTypeIterator extends \ArrayIterator
{
    public function current()
    {
        return new \SplFileInfo(parent::current());
    }

    public function isFile()
    {
        return $this->current()->isFile();
    }

    public function isDir()
    {
        return $this->current()->isDir();
    }
}

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
dependabot-composer-0.112.1 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.111.57 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.111.56 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.111.52 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.111.50 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.111.25 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.111.17 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.111.15 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.110.13 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.108.11 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.108.8 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.107.47 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.107.39 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.107.36 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.107.28 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.107.14 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php