ConditionalNodeTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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\ConditionalNode;
  12. use Symfony\Component\ExpressionLanguage\Node\ConstantNode;
  13. class ConditionalNodeTest extends AbstractNodeTest
  14. {
  15. public function getEvaluateData()
  16. {
  17. return [
  18. [1, new ConditionalNode(new ConstantNode(true), new ConstantNode(1), new ConstantNode(2))],
  19. [2, new ConditionalNode(new ConstantNode(false), new ConstantNode(1), new ConstantNode(2))],
  20. ];
  21. }
  22. public function getCompileData()
  23. {
  24. return [
  25. ['((true) ? (1) : (2))', new ConditionalNode(new ConstantNode(true), new ConstantNode(1), new ConstantNode(2))],
  26. ['((false) ? (1) : (2))', new ConditionalNode(new ConstantNode(false), new ConstantNode(1), new ConstantNode(2))],
  27. ];
  28. }
  29. public function getDumpData()
  30. {
  31. return [
  32. ['(true ? 1 : 2)', new ConditionalNode(new ConstantNode(true), new ConstantNode(1), new ConstantNode(2))],
  33. ['(false ? 1 : 2)', new ConditionalNode(new ConstantNode(false), new ConstantNode(1), new ConstantNode(2))],
  34. ];
  35. }
  36. }