Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / symfony / finder / Tests / Iterator / FilterIteratorTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\Finder\Tests\Iterator;
13
14 /**
15  * @author Alex Bogomazov
16  *
17  * @group legacy
18  */
19 class FilterIteratorTest extends RealIteratorTestCase
20 {
21     public function testFilterFilesystemIterators()
22     {
23         $i = new \FilesystemIterator($this->toAbsolute());
24
25         // it is expected that there are test.py test.php in the tmpDir
26         $i = $this->getMockForAbstractClass('Symfony\Component\Finder\Iterator\FilterIterator', array($i));
27         $i->expects($this->any())
28             ->method('accept')
29             ->will($this->returnCallback(function () use ($i) {
30                 return (bool) preg_match('/\.php/', (string) $i->current());
31             })
32         );
33
34         $c = 0;
35         foreach ($i as $item) {
36             ++$c;
37         }
38
39         $this->assertEquals(1, $c);
40
41         $i->rewind();
42
43         $c = 0;
44         foreach ($i as $item) {
45             ++$c;
46         }
47
48         // This would fail in php older than 5.5.23/5.6.7 with \FilterIterator
49         // but works with Symfony\Component\Finder\Iterator\FilterIterator
50         // see https://bugs.php.net/68557
51         $this->assertEquals(1, $c);
52     }
53 }