TYPO3  7.6
DepthRangeFilterIteratorTest.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($minDepth, $maxDepth, $expected)
22  {
23  $inner = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->toAbsolute(), \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
24 
25  $iterator = new DepthRangeFilterIterator($inner, $minDepth, $maxDepth);
26 
27  $actual = array_keys(iterator_to_array($iterator));
28  sort($expected);
29  sort($actual);
30  $this->assertEquals($expected, $actual);
31  }
32 
33  public function getAcceptData()
34  {
35  $lessThan1 = array(
36  '.git',
37  'test.py',
38  'foo',
39  'test.php',
40  'toto',
41  '.foo',
42  '.bar',
43  'foo bar',
44  );
45 
46  $lessThanOrEqualTo1 = array(
47  '.git',
48  'test.py',
49  'foo',
50  'foo/bar.tmp',
51  'test.php',
52  'toto',
53  '.foo',
54  '.foo/.bar',
55  '.bar',
56  'foo bar',
57  '.foo/bar',
58  );
59 
60  $graterThanOrEqualTo1 = array(
61  'foo/bar.tmp',
62  '.foo/.bar',
63  '.foo/bar',
64  );
65 
66  $equalTo1 = array(
67  'foo/bar.tmp',
68  '.foo/.bar',
69  '.foo/bar',
70  );
71 
72  return array(
73  array(0, 0, $this->toAbsolute($lessThan1)),
74  array(0, 1, $this->toAbsolute($lessThanOrEqualTo1)),
75  array(2, PHP_INT_MAX, array()),
76  array(1, PHP_INT_MAX, $this->toAbsolute($graterThanOrEqualTo1)),
77  array(1, 1, $this->toAbsolute($equalTo1)),
78  );
79  }
80 }