Sha256: f2d962c71ec3cfd4557e74a60a34066ca8faf76ffee1d3ee0a5dda8dc599781c

Contents?: true

Size: 1.85 KB

Versions: 24

Compression:

Stored size: 1.85 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 = array(
            '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 = array(
            '.git',
            'foo',
            'qux',
            'toto',
            'toto/.git',
            '.foo',
        );

        return array(
            array(FileTypeFilterIterator::ONLY_FILES, $this->toAbsolute($onlyFiles)),
            array(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

24 entries across 24 versions & 1 rubygems

Version Path
dependabot-composer-0.106.12 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.106.11 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.106.5 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.100.2 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.98.36 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.98.19 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.98.13 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.98.11 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.98.10 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.98.7 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.98.6 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.98.1 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.95.70 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.95.63 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.95.60 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.95.52 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.95.50 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.95.47 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.95.42 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php
dependabot-composer-0.95.40 helpers/vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php