ConstantNodeTest.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. class ConstantNodeTest extends AbstractNodeTest
  13. {
  14. public function getEvaluateData()
  15. {
  16. return [
  17. [false, new ConstantNode(false)],
  18. [true, new ConstantNode(true)],
  19. [null, new ConstantNode(null)],
  20. [3, new ConstantNode(3)],
  21. [3.3, new ConstantNode(3.3)],
  22. ['foo', new ConstantNode('foo')],
  23. [[1, 'b' => 'a'], new ConstantNode([1, 'b' => 'a'])],
  24. ];
  25. }
  26. public function getCompileData()
  27. {
  28. return [
  29. ['false', new ConstantNode(false)],
  30. ['true', new ConstantNode(true)],
  31. ['null', new ConstantNode(null)],
  32. ['3', new ConstantNode(3)],
  33. ['3.3', new ConstantNode(3.3)],
  34. ['"foo"', new ConstantNode('foo')],
  35. ['[0 => 1, "b" => "a"]', new ConstantNode([1, 'b' => 'a'])],
  36. ];
  37. }
  38. public function getDumpData()
  39. {
  40. return [
  41. ['false', new ConstantNode(false)],
  42. ['true', new ConstantNode(true)],
  43. ['null', new ConstantNode(null)],
  44. ['3', new ConstantNode(3)],
  45. ['3.3', new ConstantNode(3.3)],
  46. ['"foo"', new ConstantNode('foo')],
  47. ['foo', new ConstantNode('foo', true)],
  48. ['{0: 1, "b": "a", 1: true}', new ConstantNode([1, 'b' => 'a', true])],
  49. ['{"a\\"b": "c", "a\\\\b": "d"}', new ConstantNode(['a"b' => 'c', 'a\\b' => 'd'])],
  50. ['["c", "d"]', new ConstantNode(['c', 'd'])],
  51. ['{"a": ["b"]}', new ConstantNode(['a' => ['b']])],
  52. ];
  53. }
  54. }