Drupal investigation

ExpressionTest.php 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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\Expression;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\Finder\Expression\Expression;
  13. /**
  14. * @group legacy
  15. */
  16. class ExpressionTest extends TestCase
  17. {
  18. /**
  19. * @dataProvider getTypeGuesserData
  20. */
  21. public function testTypeGuesser($expr, $type)
  22. {
  23. $this->assertEquals($type, Expression::create($expr)->getType());
  24. }
  25. /**
  26. * @dataProvider getCaseSensitiveData
  27. */
  28. public function testCaseSensitive($expr, $isCaseSensitive)
  29. {
  30. $this->assertEquals($isCaseSensitive, Expression::create($expr)->isCaseSensitive());
  31. }
  32. /**
  33. * @dataProvider getRegexRenderingData
  34. */
  35. public function testRegexRendering($expr, $body)
  36. {
  37. $this->assertEquals($body, Expression::create($expr)->renderPattern());
  38. }
  39. public function getTypeGuesserData()
  40. {
  41. return array(
  42. array('{foo}', Expression::TYPE_REGEX),
  43. array('/foo/', Expression::TYPE_REGEX),
  44. array('foo', Expression::TYPE_GLOB),
  45. array('foo*', Expression::TYPE_GLOB),
  46. );
  47. }
  48. public function getCaseSensitiveData()
  49. {
  50. return array(
  51. array('{foo}m', true),
  52. array('/foo/i', false),
  53. array('foo*', true),
  54. );
  55. }
  56. public function getRegexRenderingData()
  57. {
  58. return array(
  59. array('{foo}m', 'foo'),
  60. array('/foo/i', 'foo'),
  61. );
  62. }
  63. }