13
13
14
14
use PHPUnit \Framework \TestCase ;
15
15
use Symfony \Bridge \Twig \Node \SearchAndRenderBlockNode ;
16
+ use Twig \Attribute \FirstClassTwigCallableReady ;
16
17
use Twig \Compiler ;
17
18
use Twig \Environment ;
18
19
use Twig \Extension \CoreExtension ;
22
23
use Twig \Node \Expression \ConstantExpression ;
23
24
use Twig \Node \Expression \NameExpression ;
24
25
use Twig \Node \Node ;
26
+ use Twig \TwigFunction ;
25
27
26
28
class SearchAndRenderBlockNodeTest extends TestCase
27
29
{
@@ -31,7 +33,11 @@ public function testCompileWidget()
31
33
new NameExpression ('form ' , 0 ),
32
34
]);
33
35
34
- $ node = new SearchAndRenderBlockNode ('form_widget ' , $ arguments , 0 );
36
+ if (class_exists (FirstClassTwigCallableReady::class)) {
37
+ $ node = new SearchAndRenderBlockNode (new TwigFunction ('form_widget ' ), $ arguments , 0 );
38
+ } else {
39
+ $ node = new SearchAndRenderBlockNode ('form_widget ' , $ arguments , 0 );
40
+ }
35
41
36
42
$ compiler = new Compiler (new Environment ($ this ->createMock (LoaderInterface::class)));
37
43
@@ -54,7 +60,11 @@ public function testCompileWidgetWithVariables()
54
60
], 0 ),
55
61
]);
56
62
57
- $ node = new SearchAndRenderBlockNode ('form_widget ' , $ arguments , 0 );
63
+ if (class_exists (FirstClassTwigCallableReady::class)) {
64
+ $ node = new SearchAndRenderBlockNode (new TwigFunction ('form_widget ' ), $ arguments , 0 );
65
+ } else {
66
+ $ node = new SearchAndRenderBlockNode ('form_widget ' , $ arguments , 0 );
67
+ }
58
68
59
69
$ compiler = new Compiler (new Environment ($ this ->createMock (LoaderInterface::class)));
60
70
@@ -74,7 +84,11 @@ public function testCompileLabelWithLabel()
74
84
new ConstantExpression ('my label ' , 0 ),
75
85
]);
76
86
77
- $ node = new SearchAndRenderBlockNode ('form_label ' , $ arguments , 0 );
87
+ if (class_exists (FirstClassTwigCallableReady::class)) {
88
+ $ node = new SearchAndRenderBlockNode (new TwigFunction ('form_label ' ), $ arguments , 0 );
89
+ } else {
90
+ $ node = new SearchAndRenderBlockNode ('form_label ' , $ arguments , 0 );
91
+ }
78
92
79
93
$ compiler = new Compiler (new Environment ($ this ->createMock (LoaderInterface::class)));
80
94
@@ -94,7 +108,11 @@ public function testCompileLabelWithNullLabel()
94
108
new ConstantExpression (null , 0 ),
95
109
]);
96
110
97
- $ node = new SearchAndRenderBlockNode ('form_label ' , $ arguments , 0 );
111
+ if (class_exists (FirstClassTwigCallableReady::class)) {
112
+ $ node = new SearchAndRenderBlockNode (new TwigFunction ('form_label ' ), $ arguments , 0 );
113
+ } else {
114
+ $ node = new SearchAndRenderBlockNode ('form_label ' , $ arguments , 0 );
115
+ }
98
116
99
117
$ compiler = new Compiler (new Environment ($ this ->createMock (LoaderInterface::class)));
100
118
@@ -116,7 +134,11 @@ public function testCompileLabelWithEmptyStringLabel()
116
134
new ConstantExpression ('' , 0 ),
117
135
]);
118
136
119
- $ node = new SearchAndRenderBlockNode ('form_label ' , $ arguments , 0 );
137
+ if (class_exists (FirstClassTwigCallableReady::class)) {
138
+ $ node = new SearchAndRenderBlockNode (new TwigFunction ('form_label ' ), $ arguments , 0 );
139
+ } else {
140
+ $ node = new SearchAndRenderBlockNode ('form_label ' , $ arguments , 0 );
141
+ }
120
142
121
143
$ compiler = new Compiler (new Environment ($ this ->createMock (LoaderInterface::class)));
122
144
@@ -137,7 +159,11 @@ public function testCompileLabelWithDefaultLabel()
137
159
new NameExpression ('form ' , 0 ),
138
160
]);
139
161
140
- $ node = new SearchAndRenderBlockNode ('form_label ' , $ arguments , 0 );
162
+ if (class_exists (FirstClassTwigCallableReady::class)) {
163
+ $ node = new SearchAndRenderBlockNode (new TwigFunction ('form_label ' ), $ arguments , 0 );
164
+ } else {
165
+ $ node = new SearchAndRenderBlockNode ('form_label ' , $ arguments , 0 );
166
+ }
141
167
142
168
$ compiler = new Compiler (new Environment ($ this ->createMock (LoaderInterface::class)));
143
169
@@ -161,7 +187,11 @@ public function testCompileLabelWithAttributes()
161
187
], 0 ),
162
188
]);
163
189
164
- $ node = new SearchAndRenderBlockNode ('form_label ' , $ arguments , 0 );
190
+ if (class_exists (FirstClassTwigCallableReady::class)) {
191
+ $ node = new SearchAndRenderBlockNode (new TwigFunction ('form_label ' ), $ arguments , 0 );
192
+ } else {
193
+ $ node = new SearchAndRenderBlockNode ('form_label ' , $ arguments , 0 );
194
+ }
165
195
166
196
$ compiler = new Compiler (new Environment ($ this ->createMock (LoaderInterface::class)));
167
197
@@ -190,7 +220,11 @@ public function testCompileLabelWithLabelAndAttributes()
190
220
], 0 ),
191
221
]);
192
222
193
- $ node = new SearchAndRenderBlockNode ('form_label ' , $ arguments , 0 );
223
+ if (class_exists (FirstClassTwigCallableReady::class)) {
224
+ $ node = new SearchAndRenderBlockNode (new TwigFunction ('form_label ' ), $ arguments , 0 );
225
+ } else {
226
+ $ node = new SearchAndRenderBlockNode ('form_label ' , $ arguments , 0 );
227
+ }
194
228
195
229
$ compiler = new Compiler (new Environment ($ this ->createMock (LoaderInterface::class)));
196
230
@@ -218,7 +252,11 @@ public function testCompileLabelWithLabelThatEvaluatesToNull()
218
252
),
219
253
]);
220
254
221
- $ node = new SearchAndRenderBlockNode ('form_label ' , $ arguments , 0 );
255
+ if (class_exists (FirstClassTwigCallableReady::class)) {
256
+ $ node = new SearchAndRenderBlockNode (new TwigFunction ('form_label ' ), $ arguments , 0 );
257
+ } else {
258
+ $ node = new SearchAndRenderBlockNode ('form_label ' , $ arguments , 0 );
259
+ }
222
260
223
261
$ compiler = new Compiler (new Environment ($ this ->createMock (LoaderInterface::class)));
224
262
@@ -256,7 +294,11 @@ public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes()
256
294
], 0 ),
257
295
]);
258
296
259
- $ node = new SearchAndRenderBlockNode ('form_label ' , $ arguments , 0 );
297
+ if (class_exists (FirstClassTwigCallableReady::class)) {
298
+ $ node = new SearchAndRenderBlockNode (new TwigFunction ('form_label ' ), $ arguments , 0 );
299
+ } else {
300
+ $ node = new SearchAndRenderBlockNode ('form_label ' , $ arguments , 0 );
301
+ }
260
302
261
303
$ compiler = new Compiler (new Environment ($ this ->createMock (LoaderInterface::class)));
262
304
0 commit comments