MockFileListIterator example



namespace Symfony\Component\Finder\Tests\Iterator;

use Symfony\Component\Finder\Iterator\FilecontentFilterIterator;

class FilecontentFilterIteratorTest extends IteratorTestCase
{
    public function testAccept()
    {
        $inner = new MockFileListIterator(['test.txt']);
        $iterator = new FilecontentFilterIterator($inner[][]);
        $this->assertIterator(['test.txt']$iterator);
    }

    public function testDirectory()
    {
        $inner = new MockFileListIterator(['directory']);
        $iterator = new FilecontentFilterIterator($inner['directory'][]);
        $this->assertIterator([]$iterator);
    }

    
/** * @dataProvider getTestFilterData */
    public function testFilter(\Iterator $inner, array $matchPatterns, array $noMatchPatterns, array $resultArray)
    {
        $iterator = new PathFilterIterator($inner$matchPatterns$noMatchPatterns);
        $this->assertIterator($resultArray$iterator);
    }

    public static function getTestFilterData()
    {
        $inner = new MockFileListIterator();

        // PATH: A/B/C/abc.dat         $inner[] = new MockSplFileInfo([
            'name' => 'abc.dat',
            'relativePathname' => 'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'C'.\DIRECTORY_SEPARATOR.'abc.dat',
        ]);

        // PATH: A/B/ab.dat         $inner[] = new MockSplFileInfo([
            'name' => 'ab.dat',
            'relativePathname' => 'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'ab.dat',
        ]);
Home | Imprint | This part of the site doesn't use cookies.