FunctionNodeTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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\Node;
  11. use Symfony\Component\ExpressionLanguage\Node\ConstantNode;
  12. use Symfony\Component\ExpressionLanguage\Node\FunctionNode;
  13. use Symfony\Component\ExpressionLanguage\Node\Node;
  14. class FunctionNodeTest extends AbstractNodeTest
  15. {
  16. public function getEvaluateData()
  17. {
  18. return [
  19. ['bar', new FunctionNode('foo', new Node([new ConstantNode('bar')])), [], ['foo' => $this->getCallables()]],
  20. ];
  21. }
  22. public function getCompileData()
  23. {
  24. return [
  25. ['foo("bar")', new FunctionNode('foo', new Node([new ConstantNode('bar')])), ['foo' => $this->getCallables()]],
  26. ];
  27. }
  28. public function getDumpData()
  29. {
  30. return [
  31. ['foo("bar")', new FunctionNode('foo', new Node([new ConstantNode('bar')])), ['foo' => $this->getCallables()]],
  32. ];
  33. }
  34. protected function getCallables()
  35. {
  36. return [
  37. 'compiler' => function ($arg) {
  38. return sprintf('foo(%s)', $arg);
  39. },
  40. 'evaluator' => function ($variables, $arg) {
  41. return $arg;
  42. },
  43. ];
  44. }
  45. }