2020use Twig \Node \Expression \ArrayExpression ;
2121use Twig \Node \Expression \ConditionalExpression ;
2222use Twig \Node \Expression \ConstantExpression ;
23- use Twig \Node \Expression \NameExpression ;
2423use Twig \Node \Expression \Ternary \ConditionalTernary ;
2524use Twig \Node \Expression \Variable \ContextVariable ;
26- use Twig \Node \Node ;
2725use Twig \Node \Nodes ;
2826use Twig \TwigFunction ;
2927
3028class SearchAndRenderBlockNodeTest extends TestCase
3129{
3230 public function testCompileWidget ()
3331 {
34- if (class_exists (Nodes::class)) {
35- $ arguments = new Nodes ([
36- new ContextVariable ('form ' , 0 ),
37- ]);
38- } else {
39- $ arguments = new Node ([
40- new NameExpression ('form ' , 0 ),
41- ]);
42- }
32+ $ arguments = new Nodes ([
33+ new ContextVariable ('form ' , 0 ),
34+ ]);
4335
4436 $ node = new SearchAndRenderBlockNode (new TwigFunction ('form_widget ' ), $ arguments , 0 );
4537
@@ -56,23 +48,13 @@ public function testCompileWidget()
5648
5749 public function testCompileWidgetWithVariables ()
5850 {
59- if (class_exists (Nodes::class)) {
60- $ arguments = new Nodes ([
61- new ContextVariable ('form ' , 0 ),
62- new ArrayExpression ([
63- new ConstantExpression ('foo ' , 0 ),
64- new ConstantExpression ('bar ' , 0 ),
65- ], 0 ),
66- ]);
67- } else {
68- $ arguments = new Node ([
69- new NameExpression ('form ' , 0 ),
70- new ArrayExpression ([
71- new ConstantExpression ('foo ' , 0 ),
72- new ConstantExpression ('bar ' , 0 ),
73- ], 0 ),
74- ]);
75- }
51+ $ arguments = new Nodes ([
52+ new ContextVariable ('form ' , 0 ),
53+ new ArrayExpression ([
54+ new ConstantExpression ('foo ' , 0 ),
55+ new ConstantExpression ('bar ' , 0 ),
56+ ], 0 ),
57+ ]);
7658
7759 $ node = new SearchAndRenderBlockNode (new TwigFunction ('form_widget ' ), $ arguments , 0 );
7860
@@ -89,17 +71,10 @@ public function testCompileWidgetWithVariables()
8971
9072 public function testCompileLabelWithLabel ()
9173 {
92- if (class_exists (Nodes::class)) {
93- $ arguments = new Nodes ([
94- new ContextVariable ('form ' , 0 ),
95- new ConstantExpression ('my label ' , 0 ),
96- ]);
97- } else {
98- $ arguments = new Node ([
99- new NameExpression ('form ' , 0 ),
100- new ConstantExpression ('my label ' , 0 ),
101- ]);
102- }
74+ $ arguments = new Nodes ([
75+ new ContextVariable ('form ' , 0 ),
76+ new ConstantExpression ('my label ' , 0 ),
77+ ]);
10378
10479 $ node = new SearchAndRenderBlockNode (new TwigFunction ('form_label ' ), $ arguments , 0 );
10580
@@ -116,17 +91,10 @@ public function testCompileLabelWithLabel()
11691
11792 public function testCompileLabelWithNullLabel ()
11893 {
119- if (class_exists (Nodes::class)) {
120- $ arguments = new Nodes ([
121- new ContextVariable ('form ' , 0 ),
122- new ConstantExpression (null , 0 ),
123- ]);
124- } else {
125- $ arguments = new Node ([
126- new NameExpression ('form ' , 0 ),
127- new ConstantExpression (null , 0 ),
128- ]);
129- }
94+ $ arguments = new Nodes ([
95+ new ContextVariable ('form ' , 0 ),
96+ new ConstantExpression (null , 0 ),
97+ ]);
13098
13199 $ node = new SearchAndRenderBlockNode (new TwigFunction ('form_label ' ), $ arguments , 0 );
132100
@@ -145,17 +113,10 @@ public function testCompileLabelWithNullLabel()
145113
146114 public function testCompileLabelWithEmptyStringLabel ()
147115 {
148- if (class_exists (Nodes::class)) {
149- $ arguments = new Nodes ([
150- new ContextVariable ('form ' , 0 ),
151- new ConstantExpression ('' , 0 ),
152- ]);
153- } else {
154- $ arguments = new Node ([
155- new NameExpression ('form ' , 0 ),
156- new ConstantExpression ('' , 0 ),
157- ]);
158- }
116+ $ arguments = new Nodes ([
117+ new ContextVariable ('form ' , 0 ),
118+ new ConstantExpression ('' , 0 ),
119+ ]);
159120
160121 $ node = new SearchAndRenderBlockNode (new TwigFunction ('form_label ' ), $ arguments , 0 );
161122
@@ -174,15 +135,9 @@ public function testCompileLabelWithEmptyStringLabel()
174135
175136 public function testCompileLabelWithDefaultLabel ()
176137 {
177- if (class_exists (Nodes::class)) {
178- $ arguments = new Nodes ([
179- new ContextVariable ('form ' , 0 ),
180- ]);
181- } else {
182- $ arguments = new Node ([
183- new NameExpression ('form ' , 0 ),
184- ]);
185- }
138+ $ arguments = new Nodes ([
139+ new ContextVariable ('form ' , 0 ),
140+ ]);
186141
187142 $ node = new SearchAndRenderBlockNode (new TwigFunction ('form_label ' ), $ arguments , 0 );
188143
@@ -199,25 +154,14 @@ public function testCompileLabelWithDefaultLabel()
199154
200155 public function testCompileLabelWithAttributes ()
201156 {
202- if (class_exists (Nodes::class)) {
203- $ arguments = new Nodes ([
204- new ContextVariable ('form ' , 0 ),
205- new ConstantExpression (null , 0 ),
206- new ArrayExpression ([
207- new ConstantExpression ('foo ' , 0 ),
208- new ConstantExpression ('bar ' , 0 ),
209- ], 0 ),
210- ]);
211- } else {
212- $ arguments = new Node ([
213- new NameExpression ('form ' , 0 ),
214- new ConstantExpression (null , 0 ),
215- new ArrayExpression ([
216- new ConstantExpression ('foo ' , 0 ),
217- new ConstantExpression ('bar ' , 0 ),
218- ], 0 ),
219- ]);
220- }
157+ $ arguments = new Nodes ([
158+ new ContextVariable ('form ' , 0 ),
159+ new ConstantExpression (null , 0 ),
160+ new ArrayExpression ([
161+ new ConstantExpression ('foo ' , 0 ),
162+ new ConstantExpression ('bar ' , 0 ),
163+ ], 0 ),
164+ ]);
221165
222166 $ node = new SearchAndRenderBlockNode (new TwigFunction ('form_label ' ), $ arguments , 0 );
223167
@@ -237,29 +181,16 @@ public function testCompileLabelWithAttributes()
237181
238182 public function testCompileLabelWithLabelAndAttributes ()
239183 {
240- if (class_exists (Nodes::class)) {
241- $ arguments = new Nodes ([
242- new ContextVariable ('form ' , 0 ),
243- new ConstantExpression ('value in argument ' , 0 ),
244- new ArrayExpression ([
245- new ConstantExpression ('foo ' , 0 ),
246- new ConstantExpression ('bar ' , 0 ),
247- new ConstantExpression ('label ' , 0 ),
248- new ConstantExpression ('value in attributes ' , 0 ),
249- ], 0 ),
250- ]);
251- } else {
252- $ arguments = new Node ([
253- new NameExpression ('form ' , 0 ),
254- new ConstantExpression ('value in argument ' , 0 ),
255- new ArrayExpression ([
256- new ConstantExpression ('foo ' , 0 ),
257- new ConstantExpression ('bar ' , 0 ),
258- new ConstantExpression ('label ' , 0 ),
259- new ConstantExpression ('value in attributes ' , 0 ),
260- ], 0 ),
261- ]);
262- }
184+ $ arguments = new Nodes ([
185+ new ContextVariable ('form ' , 0 ),
186+ new ConstantExpression ('value in argument ' , 0 ),
187+ new ArrayExpression ([
188+ new ConstantExpression ('foo ' , 0 ),
189+ new ConstantExpression ('bar ' , 0 ),
190+ new ConstantExpression ('label ' , 0 ),
191+ new ConstantExpression ('value in attributes ' , 0 ),
192+ ], 0 ),
193+ ]);
263194
264195 $ node = new SearchAndRenderBlockNode (new TwigFunction ('form_label ' ), $ arguments , 0 );
265196
@@ -298,11 +229,7 @@ public function testCompileLabelWithLabelThatEvaluatesToNull()
298229 );
299230 }
300231
301- if (class_exists (Nodes::class)) {
302- $ arguments = new Nodes ([new ContextVariable ('form ' , 0 ), $ conditional ]);
303- } else {
304- $ arguments = new Node ([new NameExpression ('form ' , 0 ), $ conditional ]);
305- }
232+ $ arguments = new Nodes ([new ContextVariable ('form ' , 0 ), $ conditional ]);
306233
307234 $ node = new SearchAndRenderBlockNode (new TwigFunction ('form_label ' ), $ arguments , 0 );
308235
@@ -345,29 +272,16 @@ public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes()
345272 );
346273 }
347274
348- if (class_exists (Nodes::class)) {
349- $ arguments = new Nodes ([
350- new ContextVariable ('form ' , 0 ),
351- $ conditional ,
352- new ArrayExpression ([
353- new ConstantExpression ('foo ' , 0 ),
354- new ConstantExpression ('bar ' , 0 ),
355- new ConstantExpression ('label ' , 0 ),
356- new ConstantExpression ('value in attributes ' , 0 ),
357- ], 0 ),
358- ]);
359- } else {
360- $ arguments = new Node ([
361- new NameExpression ('form ' , 0 ),
362- $ conditional ,
363- new ArrayExpression ([
364- new ConstantExpression ('foo ' , 0 ),
365- new ConstantExpression ('bar ' , 0 ),
366- new ConstantExpression ('label ' , 0 ),
367- new ConstantExpression ('value in attributes ' , 0 ),
368- ], 0 ),
369- ]);
370- }
275+ $ arguments = new Nodes ([
276+ new ContextVariable ('form ' , 0 ),
277+ $ conditional ,
278+ new ArrayExpression ([
279+ new ConstantExpression ('foo ' , 0 ),
280+ new ConstantExpression ('bar ' , 0 ),
281+ new ConstantExpression ('label ' , 0 ),
282+ new ConstantExpression ('value in attributes ' , 0 ),
283+ ], 0 ),
284+ ]);
371285
372286 $ node = new SearchAndRenderBlockNode (new TwigFunction ('form_label ' ), $ arguments , 0 );
373287
0 commit comments