Yaffs site version 1.1
[yaffs-website] / vendor / symfony / finder / Tests / Expression / GlobTest.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\Expression;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Finder\Expression\Expression;
16
17 /**
18  * @group legacy
19  */
20 class GlobTest extends TestCase
21 {
22     /**
23      * @dataProvider getToRegexData
24      */
25     public function testGlobToRegex($glob, $match, $noMatch)
26     {
27         foreach ($match as $m) {
28             $this->assertRegExp(Expression::create($glob)->getRegex()->render(), $m, '::toRegex() converts a glob to a regexp');
29         }
30
31         foreach ($noMatch as $m) {
32             $this->assertNotRegExp(Expression::create($glob)->getRegex()->render(), $m, '::toRegex() converts a glob to a regexp');
33         }
34     }
35
36     public function getToRegexData()
37     {
38         return array(
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')),
49         );
50     }
51 }