PageRenderTime 50ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/_app/vendor/Symfony/Component/Finder/Tests/Expression/GlobTest.php

https://bitbucket.org/sirestudios/fortis-wellness
PHP | 47 lines | 30 code | 6 blank | 11 comment | 0 complexity | 2f1b92614c48ee451650dd0bc994580a MD5 | raw file
Possible License(s): JSON
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Finder\Tests;
  11. use Symfony\Component\Finder\Expression\Expression;
  12. class GlobTest extends \PHPUnit_Framework_TestCase
  13. {
  14. /**
  15. * @dataProvider getToRegexData
  16. */
  17. public function testGlobToRegex($glob, $match, $noMatch)
  18. {
  19. foreach ($match as $m) {
  20. $this->assertRegExp(Expression::create($glob)->getRegex()->render(), $m, '::toRegex() converts a glob to a regexp');
  21. }
  22. foreach ($noMatch as $m) {
  23. $this->assertNotRegExp(Expression::create($glob)->getRegex()->render(), $m, '::toRegex() converts a glob to a regexp');
  24. }
  25. }
  26. public function getToRegexData()
  27. {
  28. return array(
  29. array('', array(''), array('f', '/')),
  30. array('*', array('foo'), array('foo/', '/foo')),
  31. array('foo.*', array('foo.php', 'foo.a', 'foo.'), array('fooo.php', 'foo.php/foo')),
  32. array('fo?', array('foo', 'fot'), array('fooo', 'ffoo', 'fo/')),
  33. array('fo{o,t}', array('foo', 'fot'), array('fob', 'fo/')),
  34. array('foo(bar|foo)', array('foo(bar|foo)'), array('foobar', 'foofoo')),
  35. array('foo,bar', array('foo,bar'), array('foo', 'bar')),
  36. array('fo{o,\\,}', array('foo', 'fo,'), array()),
  37. array('fo{o,\\\\}', array('foo', 'fo\\'), array()),
  38. array('/foo', array('/foo'), array('foo')),
  39. );
  40. }
  41. }