ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Twig_Tests_Node_IfTest Class Reference
+ Inheritance diagram for Twig_Tests_Node_IfTest:
+ Collaboration diagram for Twig_Tests_Node_IfTest:

Public Member Functions

 testConstructor ()
 
 getTests ()
 
- Public Member Functions inherited from Twig_Test_NodeTestCase
 getTests ()
 
 testCompile ($node, $source, $environment=null, $isPattern=false)
 getTests More...
 
 assertNodeCompilation ($source, Twig_Node $node, Twig_Environment $environment=null, $isPattern=false)
 

Additional Inherited Members

- Protected Member Functions inherited from Twig_Test_NodeTestCase
 getCompiler (Twig_Environment $environment=null)
 
 getEnvironment ()
 
 getVariableGetter ($name, $line=false)
 
 getAttributeGetter ()
 

Detailed Description

Definition at line 12 of file IfTest.php.

Member Function Documentation

◆ getTests()

Twig_Tests_Node_IfTest::getTests ( )

Definition at line 31 of file IfTest.php.

References $t, array, EOF, and Twig_Test_NodeTestCase\getVariableGetter().

32  {
33  $tests = array();
34 
35  $t = new Twig_Node(array(
36  new Twig_Node_Expression_Constant(true, 1),
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
44 if (true) {
45  echo {$this->getVariableGetter('foo')};
46 }
47 EOF
48  );
49 
50  $t = new Twig_Node(array(
51  new Twig_Node_Expression_Constant(true, 1),
52  new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1),
53  new Twig_Node_Expression_Constant(false, 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
61 if (true) {
62  echo {$this->getVariableGetter('foo')};
63 } elseif (false) {
64  echo {$this->getVariableGetter('bar')};
65 }
66 EOF
67  );
68 
69  $t = new Twig_Node(array(
70  new Twig_Node_Expression_Constant(true, 1),
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
78 if (true) {
79  echo {$this->getVariableGetter('foo')};
80 } else {
81  echo {$this->getVariableGetter('bar')};
82 }
83 EOF
84  );
85 
86  return $tests;
87  }
Represents an if node.
Definition: If.php:18
Represents a node in the AST.
Definition: Node.php:18
Represents a node that outputs an expression.
Definition: Print.php:18
Create styles array
The data for the language used.
getVariableGetter($name, $line=false)
const EOF
How fgetc() reports an End Of File.
Definition: JSMin_lib.php:92
+ Here is the call graph for this function:

◆ testConstructor()

Twig_Tests_Node_IfTest::testConstructor ( )

Definition at line 14 of file IfTest.php.

References $t, and array.

15  {
16  $t = new Twig_Node(array(
17  new Twig_Node_Expression_Constant(true, 1),
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  }
Represents an if node.
Definition: If.php:18
Represents a node in the AST.
Definition: Node.php:18
Represents a node that outputs an expression.
Definition: Print.php:18
Create styles array
The data for the language used.

The documentation for this class was generated from the following file: