scratch – Blame information for rev
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
120 | office | 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\FilenameFilterIterator; |
||
15 | |||
16 | class FilenameFilterIteratorTest extends IteratorTestCase |
||
17 | { |
||
18 | /** |
||
19 | * @dataProvider getAcceptData |
||
20 | */ |
||
21 | public function testAccept($matchPatterns, $noMatchPatterns, $expected) |
||
22 | { |
||
23 | $inner = new InnerNameIterator(array('test.php', 'test.py', 'foo.php')); |
||
24 | |||
25 | $iterator = new FilenameFilterIterator($inner, $matchPatterns, $noMatchPatterns); |
||
26 | |||
27 | $this->assertIterator($expected, $iterator); |
||
28 | } |
||
29 | |||
30 | public function getAcceptData() |
||
31 | { |
||
32 | return array( |
||
33 | array(array('test.*'), array(), array('test.php', 'test.py')), |
||
34 | array(array(), array('test.*'), array('foo.php')), |
||
35 | array(array('*.php'), array('test.*'), array('foo.php')), |
||
36 | array(array('*.php', '*.py'), array('foo.*'), array('test.php', 'test.py')), |
||
37 | array(array('/\.php$/'), array(), array('test.php', 'foo.php')), |
||
38 | array(array(), array('/\.php$/'), array('test.py')), |
||
39 | ); |
||
40 | } |
||
41 | } |
||
42 | |||
43 | class InnerNameIterator extends \ArrayIterator |
||
44 | { |
||
45 | public function current() |
||
46 | { |
||
47 | return new \SplFileInfo(parent::current()); |
||
48 | } |
||
49 | |||
50 | public function getFilename() |
||
51 | { |
||
52 | return parent::current(); |
||
53 | } |
||
54 | } |