TYPO3  7.6
Expression/GlobTest.php
Go to the documentation of this file.
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 
13 
15 
16 class GlobTest extends \PHPUnit_Framework_TestCase
17 {
21  public function testGlobToRegex($glob, $match, $noMatch)
22  {
23  foreach ($match as $m) {
24  $this->assertRegExp(Expression::create($glob)->getRegex()->render(), $m, '::toRegex() converts a glob to a regexp');
25  }
26 
27  foreach ($noMatch as $m) {
28  $this->assertNotRegExp(Expression::create($glob)->getRegex()->render(), $m, '::toRegex() converts a glob to a regexp');
29  }
30  }
31 
32  public function getToRegexData()
33  {
34  return array(
35  array('', array(''), array('f', '/')),
36  array('*', array('foo'), array('foo/', '/foo')),
37  array('foo.*', array('foo.php', 'foo.a', 'foo.'), array('fooo.php', 'foo.php/foo')),
38  array('fo?', array('foo', 'fot'), array('fooo', 'ffoo', 'fo/')),
39  array('fo{o,t}', array('foo', 'fot'), array('fob', 'fo/')),
40  array('foo(bar|foo)', array('foo(bar|foo)'), array('foobar', 'foofoo')),
41  array('foo,bar', array('foo,bar'), array('foo', 'bar')),
42  array('fo{o,\\,}', array('foo', 'fo,'), array()),
43  array('fo{o,\\\\}', array('foo', 'fo\\'), array()),
44  array('/foo', array('/foo'), array('foo')),
45  );
46  }
47 }