TYPO3  7.6
FileTypeFilterIteratorTest.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 
15 
17 {
21  public function testAccept($mode, $expected)
22  {
23  $inner = new InnerTypeIterator(self::$files);
24 
25  $iterator = new FileTypeFilterIterator($inner, $mode);
26 
27  $this->assertIterator($expected, $iterator);
28  }
29 
30  public function getAcceptData()
31  {
32  $onlyFiles = array(
33  'test.py',
34  'foo/bar.tmp',
35  'test.php',
36  '.bar',
37  '.foo/.bar',
38  '.foo/bar',
39  'foo bar',
40  );
41 
42  $onlyDirectories = array(
43  '.git',
44  'foo',
45  'toto',
46  '.foo',
47  );
48 
49  return array(
50  array(FileTypeFilterIterator::ONLY_FILES, $this->toAbsolute($onlyFiles)),
51  array(FileTypeFilterIterator::ONLY_DIRECTORIES, $this->toAbsolute($onlyDirectories)),
52  );
53  }
54 }
55 
56 class InnerTypeIterator extends \ArrayIterator
57 {
58  public function current()
59  {
60  return new \SplFileInfo(parent::current());
61  }
62 
63  public function isFile()
64  {
65  return $this->current()->isFile();
66  }
67 
68  public function isDir()
69  {
70  return $this->current()->isDir();
71  }
72 }