20
20
use Twig \Node \Expression \ArrayExpression ;
21
21
use Twig \Node \Expression \ConditionalExpression ;
22
22
use Twig \Node \Expression \ConstantExpression ;
23
- use Twig \Node \Expression \NameExpression ;
24
23
use Twig \Node \Expression \Ternary \ConditionalTernary ;
25
24
use Twig \Node \Expression \Variable \ContextVariable ;
26
- use Twig \Node \Node ;
27
25
use Twig \Node \Nodes ;
28
26
use Twig \TwigFunction ;
29
27
30
28
class SearchAndRenderBlockNodeTest extends TestCase
31
29
{
32
30
public function testCompileWidget ()
33
31
{
34
- if (class_exists (Nodes::class)) {
35
- $
9E88
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
+ ]);
43
35
44
36
$ node = new SearchAndRenderBlockNode (new TwigFunction ('form_widget ' ), $ arguments , 0 );
45
37
@@ -56,23 +48,13 @@ public function testCompileWidget()
56
48
57
49
public function testCompileWidgetWithVariables ()
58
50
{
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
+ ]);
76
58
77
59
$ node = new SearchAndRenderBlockNode (new TwigFunction ('form_widget ' ), $ arguments , 0 );
78
60
@@ -89,17 +71,10 @@ public function testCompileWidgetWithVariables()
89
71
90
72
public function testCompileLabelWithLabel ()
91
73
{
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
+ ]);
103
78
104
79
$ node = new SearchAndRenderBlockNode (new TwigFunction ('form_label ' ), $ arguments , 0 );
105
80
@@ -116,17 +91,10 @@ public function testCompileLabelWithLabel()
116
91
117
92
public function testCompileLabelWithNullLabel ()
118
93
{
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
+ ]);
130
98
131
99
$ node = new SearchAndRenderBlockNode (new TwigFunction ('form_label ' ), $ arguments , 0 );
132
100
@@ -145,17 +113,10 @@ public function testCompileLabelWithNullLabel()
145
113
146
114
public function testCompileLabelWithEmptyStringLabel ()
147
115
{
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
+ ]);
159
120
160
121
$ node = new SearchAndRenderBlockNode (new TwigFunction ('form_label ' ), $ arguments , 0 );
161
122
@@ -174,15 +135,9 @@ public function testCompileLabelWithEmptyStringLabel()
174
135
175
136
public function testCompileLabelWithDefaultLabel ()
176
137
{
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
+ ]);
186
141
187
142
$ node = new SearchAndRenderBlockNode (new TwigFunction ('form_label ' ), $ arguments , 0 );
188
143
@@ -199,25 +154,14 @@ public function testCompileLabelWithDefaultLabel()
199
154
200
155
public function testCompileLabelWithAttributes ()
201
156
{
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
+ ]);
221
165
222
166
$ node = new SearchAndRenderBlockNode (new TwigFunction ('form_label ' ), $ arguments , 0 );
223
167
@@ -237,29 +181,16 @@ public function testCompileLabelWithAttributes()
237
181
238
182
public function testCompileLabelWithLabelAndAttributes ()
239
183
{
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
+ ]);
263
194
264
195
$ node = new SearchAndRenderBlockNode (new TwigFunction ('form_label ' ), $ arguments , 0 );
265
196
@@ -298,11 +229,7 @@ public function testCompileLabelWithLabelThatEvaluatesToNull()
298
229
);
299
230
}
300
231
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 ]);
306
233
307
234
$ node = new SearchAndRenderBlockNode (new TwigFunction ('form_label ' ), $ arguments , 0 );
308
235
@@ -345,29 +272,16 @@ public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes()
345
272
);
346
273
}
347
274
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
+ ]);
371
285
372
286
$ node = new SearchAndRenderBlockNode (new TwigFunction ('form_label ' ), $ arguments , 0 );
373
287
0 commit comments