Yaffs site version 1.1
[yaffs-website] / vendor / symfony / finder / Tests / Iterator / DepthRangeFilterIteratorTest.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 use Symfony\Component\Finder\Iterator\DepthRangeFilterIterator;
15
16 class DepthRangeFilterIteratorTest extends RealIteratorTestCase
17 {
18     /**
19      * @dataProvider getAcceptData
20      */
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             'toto/.git',
54             '.foo',
55             '.foo/.bar',
56             '.bar',
57             'foo bar',
58             '.foo/bar',
59         );
60
61         $graterThanOrEqualTo1 = array(
62             'toto/.git',
63             'foo/bar.tmp',
64             '.foo/.bar',
65             '.foo/bar',
66         );
67
68         $equalTo1 = array(
69             'toto/.git',
70             'foo/bar.tmp',
71             '.foo/.bar',
72             '.foo/bar',
73         );
74
75         return array(
76             array(0, 0, $this->toAbsolute($lessThan1)),
77             array(0, 1, $this->toAbsolute($lessThanOrEqualTo1)),
78             array(2, PHP_INT_MAX, array()),
79             array(1, PHP_INT_MAX, $this->toAbsolute($graterThanOrEqualTo1)),
80             array(1, 1, $this->toAbsolute($equalTo1)),
81         );
82     }
83 }