1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12use Twig\Node\Expression\ConditionalExpression;
13use Twig\Node\Expression\ConstantExpression;
14use Twig\Test\NodeTestCase;
15
16class Twig_Tests_Node_Expression_ConditionalTest extends NodeTestCase
17{
18    public function testConstructor()
19    {
20        $expr1 = new ConstantExpression(1, 1);
21        $expr2 = new ConstantExpression(2, 1);
22        $expr3 = new ConstantExpression(3, 1);
23        $node = new ConditionalExpression($expr1, $expr2, $expr3, 1);
24
25        $this->assertEquals($expr1, $node->getNode('expr1'));
26        $this->assertEquals($expr2, $node->getNode('expr2'));
27        $this->assertEquals($expr3, $node->getNode('expr3'));
28    }
29
30    public function getTests()
31    {
32        $tests = [];
33
34        $expr1 = new ConstantExpression(1, 1);
35        $expr2 = new ConstantExpression(2, 1);
36        $expr3 = new ConstantExpression(3, 1);
37        $node = new ConditionalExpression($expr1, $expr2, $expr3, 1);
38        $tests[] = [$node, '((1) ? (2) : (3))'];
39
40        return $tests;
41    }
42}
43