Yaffs site version 1.1
[yaffs-website] / vendor / symfony / finder / Tests / Iterator / SizeRangeFilterIteratorTest.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\SizeRangeFilterIterator;
15 use Symfony\Component\Finder\Comparator\NumberComparator;
16
17 class SizeRangeFilterIteratorTest extends RealIteratorTestCase
18 {
19     /**
20      * @dataProvider getAcceptData
21      */
22     public function testAccept($size, $expected)
23     {
24         $inner = new InnerSizeIterator(self::$files);
25
26         $iterator = new SizeRangeFilterIterator($inner, $size);
27
28         $this->assertIterator($expected, $iterator);
29     }
30
31     public function getAcceptData()
32     {
33         $lessThan1KGreaterThan05K = array(
34             '.foo',
35             '.git',
36             'foo',
37             'test.php',
38             'toto',
39             'toto/.git',
40         );
41
42         return array(
43             array(array(new NumberComparator('< 1K'), new NumberComparator('> 0.5K')), $this->toAbsolute($lessThan1KGreaterThan05K)),
44         );
45     }
46 }
47
48 class InnerSizeIterator extends \ArrayIterator
49 {
50     public function current()
51     {
52         return new \SplFileInfo(parent::current());
53     }
54
55     public function getFilename()
56     {
57         return parent::current();
58     }
59
60     public function isFile()
61     {
62         return $this->current()->isFile();
63     }
64
65     public function getSize()
66     {
67         return $this->current()->getSize();
68     }
69 }