ExpressionFunctionTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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\ExpressionLanguage\Tests;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\ExpressionLanguage\ExpressionFunction;
  13. /**
  14. * Tests ExpressionFunction.
  15. *
  16. * @author Dany Maillard <danymaillard93b@gmail.com>
  17. */
  18. class ExpressionFunctionTest extends TestCase
  19. {
  20. public function testFunctionDoesNotExist()
  21. {
  22. $this->expectException('InvalidArgumentException');
  23. $this->expectExceptionMessage('PHP function "fn_does_not_exist" does not exist.');
  24. ExpressionFunction::fromPhp('fn_does_not_exist');
  25. }
  26. public function testFunctionNamespaced()
  27. {
  28. $this->expectException('InvalidArgumentException');
  29. $this->expectExceptionMessage('An expression function name must be defined when PHP function "Symfony\Component\ExpressionLanguage\Tests\fn_namespaced" is namespaced.');
  30. ExpressionFunction::fromPhp('Symfony\Component\ExpressionLanguage\Tests\fn_namespaced');
  31. }
  32. }
  33. function fn_namespaced()
  34. {
  35. }