TYPO3  7.6
FilterIteratorTest.php
Go to the documentation of this file.
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 
18 {
20  {
21  $i = new \FilesystemIterator($this->toAbsolute());
22 
23  // it is expected that there are test.py test.php in the tmpDir
24  $i = $this->getMockForAbstractClass('Symfony\Component\Finder\Iterator\FilterIterator', array($i));
25  $i->expects($this->any())
26  ->method('accept')
27  ->will($this->returnCallback(function () use ($i) {
28  return (bool) preg_match('/\.php/', (string) $i->current());
29  })
30  );
31 
32  $c = 0;
33  foreach ($i as $item) {
34  ++$c;
35  }
36 
37  $this->assertEquals(1, $c);
38 
39  $i->rewind();
40 
41  $c = 0;
42  foreach ($i as $item) {
43  ++$c;
44  }
45 
46  // This would fail with \FilterIterator but works with Symfony\Component\Finder\Iterator\FilterIterator
47  // see https://bugs.php.net/bug.php?id=49104
48  $this->assertEquals(1, $c);
49  }
50 }