ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
IfTest.php
Go to the documentation of this file.
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
13{
14 public function testConstructor()
15 {
16 $t = new Twig_Node(array(
18 new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1),
19 ), array(), 1);
20 $else = null;
21 $node = new Twig_Node_If($t, $else, 1);
22
23 $this->assertEquals($t, $node->getNode('tests'));
24 $this->assertFalse($node->hasNode('else'));
25
26 $else = new Twig_Node_Print(new Twig_Node_Expression_Name('bar', 1), 1);
27 $node = new Twig_Node_If($t, $else, 1);
28 $this->assertEquals($else, $node->getNode('else'));
29 }
30
31 public function getTests()
32 {
33 $tests = array();
34
35 $t = new Twig_Node(array(
37 new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1),
38 ), array(), 1);
39 $else = null;
40 $node = new Twig_Node_If($t, $else, 1);
41
42 $tests[] = array($node, <<<EOF
43// line 1
44if (true) {
45 echo {$this->getVariableGetter('foo')};
46}
47EOF
48 );
49
50 $t = new Twig_Node(array(
52 new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1),
54 new Twig_Node_Print(new Twig_Node_Expression_Name('bar', 1), 1),
55 ), array(), 1);
56 $else = null;
57 $node = new Twig_Node_If($t, $else, 1);
58
59 $tests[] = array($node, <<<EOF
60// line 1
61if (true) {
62 echo {$this->getVariableGetter('foo')};
63} elseif (false) {
64 echo {$this->getVariableGetter('bar')};
65}
66EOF
67 );
68
69 $t = new Twig_Node(array(
71 new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1),
72 ), array(), 1);
73 $else = new Twig_Node_Print(new Twig_Node_Expression_Name('bar', 1), 1);
74 $node = new Twig_Node_If($t, $else, 1);
75
76 $tests[] = array($node, <<<EOF
77// line 1
78if (true) {
79 echo {$this->getVariableGetter('foo')};
80} else {
81 echo {$this->getVariableGetter('bar')};
82}
83EOF
84 );
85
86 return $tests;
87 }
88}
const EOF
How fgetc() reports an End Of File.
Definition: JSMin_lib.php:92
An exception for terminatinating execution or to throw for unit testing.
Represents an if node.
Definition: If.php:19
Represents a node that outputs an expression.
Definition: Print.php:19
Represents a node in the AST.
Definition: Node.php:19
getVariableGetter($name, $line=false)
$tests
Definition: bench.php:104