4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Finder\Tests\Iterator;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Finder\Iterator\MultiplePcreFilterIterator;
17 class MultiplePcreFilterIteratorTest extends TestCase
20 * @dataProvider getIsRegexFixtures
22 public function testIsRegex($string, $isRegex, $message)
24 $testIterator = new TestMultiplePcreFilterIterator();
25 $this->assertEquals($isRegex, $testIterator->isRegex($string), $message);
28 public function getIsRegexFixtures()
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'),
51 class TestMultiplePcreFilterIterator extends MultiplePcreFilterIterator
53 public function __construct()
57 public function accept()
59 throw new \BadFunctionCallException('Not implemented');
62 public function isRegex($str)
64 return parent::isRegex($str);
67 public function toRegex($str)
69 throw new \BadFunctionCallException('Not implemented');