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\Expression;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Finder\Expression\Expression;
20 class GlobTest extends TestCase
23 * @dataProvider getToRegexData
25 public function testGlobToRegex($glob, $match, $noMatch)
27 foreach ($match as $m) {
28 $this->assertRegExp(Expression::create($glob)->getRegex()->render(), $m, '::toRegex() converts a glob to a regexp');
31 foreach ($noMatch as $m) {
32 $this->assertNotRegExp(Expression::create($glob)->getRegex()->render(), $m, '::toRegex() converts a glob to a regexp');
36 public function getToRegexData()
39 array('', array(''), array('f', '/')),
40 array('*', array('foo'), array('foo/', '/foo')),
41 array('foo.*', array('foo.php', 'foo.a', 'foo.'), array('fooo.php', 'foo.php/foo')),
42 array('fo?', array('foo', 'fot'), array('fooo', 'ffoo', 'fo/')),
43 array('fo{o,t}', array('foo', 'fot'), array('fob', 'fo/')),
44 array('foo(bar|foo)', array('foo(bar|foo)'), array('foobar', 'foofoo')),
45 array('foo,bar', array('foo,bar'), array('foo', 'bar')),
46 array('fo{o,\\,}', array('foo', 'fo,'), array()),
47 array('fo{o,\\\\}', array('foo', 'fo\\'), array()),
48 array('/foo', array('/foo'), array('foo')),