ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
◀ ilDoc Overview
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
12
class
Twig_Tests_Node_IfTest
extends
Twig_Test_NodeTestCase
13
{
14
public
function
testConstructor
()
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
}
30
31
public
function
getTests
()
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
}
88
}
Twig_Node_If
Represents an if node.
Definition:
If.php:18
Twig_Node
Represents a node in the AST.
Definition:
Node.php:18
Twig_Tests_Node_IfTest\getTests
getTests()
Definition:
IfTest.php:31
Twig_Node_Expression_Name
Definition:
Name.php:12
Twig_Test_NodeTestCase
Definition:
NodeTestCase.php:14
Twig_Node_Print
Represents a node that outputs an expression.
Definition:
Print.php:18
Twig_Tests_Node_IfTest
Definition:
IfTest.php:12
$tests
$tests
Definition:
bench.php:104
Twig_Tests_Node_IfTest\testConstructor
testConstructor()
Definition:
IfTest.php:14
$t
$t
Definition:
authorize_403.php:14
echo
Twig_Node_Expression_Constant
Definition:
Constant.php:12
Twig_Test_NodeTestCase\getVariableGetter
getVariableGetter($name, $line=false)
Definition:
NodeTestCase.php:48
php
EOF
const EOF
How fgetc() reports an End Of File.
Definition:
JSMin_lib.php:92
libs
composer
vendor
twig
twig
test
Twig
Tests
Node
IfTest.php
Generated on Thu Feb 27 2025 19:01:36 for ILIAS by
1.8.13 (using
Doxyfile
)