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

Public Member Functions

 testConstructor ()
 
 getTests ()
 
- Public Member Functions inherited from Twig_Test_NodeTestCase
 getTests ()
 
 testCompile ($node, $source, $environment=null, $isPattern=false)
 @dataProvider 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 ModuleTest.php.

Member Function Documentation

◆ getTests()

Twig_Tests_Node_ModuleTest::getTests ( )

Reimplemented from Twig_Test_NodeTestCase.

Definition at line 31 of file ModuleTest.php.

32 {
33 $twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
34
35 $tests = array();
36
37 $body = new Twig_Node_Text('foo', 1);
38 $extends = null;
39 $blocks = new Twig_Node();
40 $macros = new Twig_Node();
41 $traits = new Twig_Node();
42 $source = new Twig_Source('{{ foo }}', 'foo.twig');
43
44 $node = new Twig_Node_Module($body, $extends, $blocks, $macros, $traits, new Twig_Node(array()), $source);
45 $tests[] = array($node, <<<EOF
46<?php
47
48/* foo.twig */
49class __TwigTemplate_%x extends Twig_Template
50{
51 public function __construct(Twig_Environment \$env)
52 {
53 parent::__construct(\$env);
54
55 \$this->parent = false;
56
57 \$this->blocks = array(
58 );
59 }
60
61 protected function doDisplay(array \$context, array \$blocks = array())
62 {
63 // line 1
64 echo "foo";
65 }
66
67 public function getTemplateName()
68 {
69 return "foo.twig";
70 }
71
72 public function getDebugInfo()
73 {
74 return array ( 19 => 1,);
75 }
76
78 public function getSource()
79 {
80 @trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', E_USER_DEPRECATED);
81
82 return \$this->getSourceContext()->getCode();
83 }
84
85 public function getSourceContext()
86 {
87 return new Twig_Source("", "foo.twig", "");
88 }
89}
90EOF
91 , $twig, true);
92
93 $import = new Twig_Node_Import(new Twig_Node_Expression_Constant('foo.twig', 1), new Twig_Node_Expression_AssignName('macro', 1), 2);
94
95 $body = new Twig_Node(array($import));
96 $extends = new Twig_Node_Expression_Constant('layout.twig', 1);
97
98 $node = new Twig_Node_Module($body, $extends, $blocks, $macros, $traits, new Twig_Node(array()), $source);
99 $tests[] = array($node, <<<EOF
100<?php
101
102/* foo.twig */
103class __TwigTemplate_%x extends Twig_Template
104{
105 public function __construct(Twig_Environment \$env)
106 {
107 parent::__construct(\$env);
108
109 // line 1
110 \$this->parent = \$this->loadTemplate("layout.twig", "foo.twig", 1);
111 \$this->blocks = array(
112 );
113 }
114
115 protected function doGetParent(array \$context)
116 {
117 return "layout.twig";
118 }
119
120 protected function doDisplay(array \$context, array \$blocks = array())
121 {
122 // line 2
123 \$context["macro"] = \$this->loadTemplate("foo.twig", "foo.twig", 2);
124 // line 1
125 \$this->parent->display(\$context, array_merge(\$this->blocks, \$blocks));
126 }
127
128 public function getTemplateName()
129 {
130 return "foo.twig";
131 }
132
133 public function isTraitable()
134 {
135 return false;
136 }
137
138 public function getDebugInfo()
139 {
140 return array ( 26 => 1, 24 => 2, 11 => 1,);
141 }
142
144 public function getSource()
145 {
146 @trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', E_USER_DEPRECATED);
147
148 return \$this->getSourceContext()->getCode();
149 }
150
151 public function getSourceContext()
152 {
153 return new Twig_Source("", "foo.twig", "");
154 }
155}
156EOF
157 , $twig, true);
158
159 $set = new Twig_Node_Set(false, new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 4))), new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 4))), 4);
160 $body = new Twig_Node(array($set));
163 new Twig_Node_Expression_Constant('foo', 2),
164 new Twig_Node_Expression_Constant('foo', 2),
165 2
166 );
167
168 $twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('debug' => true));
169 $node = new Twig_Node_Module($body, $extends, $blocks, $macros, $traits, new Twig_Node(array()), $source);
170 $tests[] = array($node, <<<EOF
171<?php
172
173/* foo.twig */
174class __TwigTemplate_%x extends Twig_Template
175{
176 protected function doGetParent(array \$context)
177 {
178 // line 2
179 return \$this->loadTemplate(((true) ? ("foo") : ("foo")), "foo.twig", 2);
180 }
181
182 protected function doDisplay(array \$context, array \$blocks = array())
183 {
184 // line 4
185 \$context["foo"] = "foo";
186 // line 2
187 \$this->getParent(\$context)->display(\$context, array_merge(\$this->blocks, \$blocks));
188 }
189
190 public function getTemplateName()
191 {
192 return "foo.twig";
193 }
194
195 public function isTraitable()
196 {
197 return false;
198 }
199
200 public function getDebugInfo()
201 {
202 return array ( 17 => 2, 15 => 4, 9 => 2,);
203 }
204
206 public function getSource()
207 {
208 @trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', E_USER_DEPRECATED);
209
210 return \$this->getSourceContext()->getCode();
211 }
212
213 public function getSourceContext()
214 {
215 return new Twig_Source("{{ foo }}", "foo.twig", "");
216 }
217}
218EOF
219 , $twig, true);
220
221 return $tests;
222 }
$env
const EOF
How fgetc() reports an End Of File.
Definition: JSMin_lib.php:92
$source
Definition: linkback.php:22
An exception for terminatinating execution or to throw for unit testing.
Stores the Twig configuration.
Definition: Environment.php:18
Represents an import node.
Definition: Import.php:18
Represents a module node.
Definition: Module.php:23
Represents a set node.
Definition: Set.php:18
Represents a text node.
Definition: Text.php:19
Represents a node in the AST.
Definition: Node.php:19
Holds information about a non-compiled Twig template.
Definition: Source.php:20
Default base class for compiled templates.
Definition: Template.php:25
loadTemplate($template, $templateName=null, $line=null, $index=null)
Definition: Template.php:351

References $env, $source, EOF, and Twig_Template\loadTemplate().

+ Here is the call graph for this function:

◆ testConstructor()

Twig_Tests_Node_ModuleTest::testConstructor ( )

Definition at line 14 of file ModuleTest.php.

15 {
16 $body = new Twig_Node_Text('foo', 1);
17 $parent = new Twig_Node_Expression_Constant('layout.twig', 1);
18 $blocks = new Twig_Node();
19 $macros = new Twig_Node();
20 $traits = new Twig_Node();
21 $source = new Twig_Source('{{ foo }}', 'foo.twig');
22 $node = new Twig_Node_Module($body, $parent, $blocks, $macros, $traits, new Twig_Node(array()), $source);
23
24 $this->assertEquals($body, $node->getNode('body'));
25 $this->assertEquals($blocks, $node->getNode('blocks'));
26 $this->assertEquals($macros, $node->getNode('macros'));
27 $this->assertEquals($parent, $node->getNode('parent'));
28 $this->assertEquals($source->getName(), $node->getTemplateName());
29 }

References $source.


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