Yaffs site version 1.1
[yaffs-website] / vendor / symfony / finder / Tests / Iterator / MultiplePcreFilterIteratorTest.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 PHPUnit\Framework\TestCase;
15 use Symfony\Component\Finder\Iterator\MultiplePcreFilterIterator;
16
17 class MultiplePcreFilterIteratorTest extends TestCase
18 {
19     /**
20      * @dataProvider getIsRegexFixtures
21      */
22     public function testIsRegex($string, $isRegex, $message)
23     {
24         $testIterator = new TestMultiplePcreFilterIterator();
25         $this->assertEquals($isRegex, $testIterator->isRegex($string), $message);
26     }
27
28     public function getIsRegexFixtures()
29     {
30         return array(
31             array('foo', false, 'string'),
32             array(' foo ', false, '" " is not a valid delimiter'),
33             array('\\foo\\', false, '"\\" is not a valid delimiter'),
34             array('afooa', false, '"a" is not a valid delimiter'),
35             array('//', false, 'the pattern should contain at least 1 character'),
36             array('/a/', true, 'valid regex'),
37             array('/foo/', true, 'valid regex'),
38             array('/foo/i', true, 'valid regex with a single modifier'),
39             array('/foo/imsxu', true, 'valid regex with multiple modifiers'),
40             array('#foo#', true, '"#" is a valid delimiter'),
41             array('{foo}', true, '"{,}" is a valid delimiter pair'),
42             array('[foo]', true, '"[,]" is a valid delimiter pair'),
43             array('(foo)', true, '"(,)" is a valid delimiter pair'),
44             array('<foo>', true, '"<,>" is a valid delimiter pair'),
45             array('*foo.*', false, '"*" is not considered as a valid delimiter'),
46             array('?foo.?', false, '"?" is not considered as a valid delimiter'),
47         );
48     }
49 }
50
51 class TestMultiplePcreFilterIterator extends MultiplePcreFilterIterator
52 {
53     public function __construct()
54     {
55     }
56
57     public function accept()
58     {
59         throw new \BadFunctionCallException('Not implemented');
60     }
61
62     public function isRegex($str)
63     {
64         return parent::isRegex($str);
65     }
66
67     public function toRegex($str)
68     {
69         throw new \BadFunctionCallException('Not implemented');
70     }
71 }