Skip to content

Commit 67c835e

Browse files
committed
Merge branch '7.1' into 7.2
* 7.1: fix Twig 3.17 compatibility
2 parents 273fa3f + aacfaa2 commit 67c835e

File tree

1 file changed

+49
-39
lines changed

1 file changed

+49
-39
lines changed

src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php

Lines changed: 49 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Twig\Node\Expression\ConditionalExpression;
2222
use Twig\Node\Expression\ConstantExpression;
2323
use Twig\Node\Expression\NameExpression;
24+
use Twig\Node\Expression\Ternary\ConditionalTernary;
2425
use Twig\Node\Expression\Variable\ContextVariable;
2526
use Twig\Node\Node;
2627
use Twig\Node\Nodes;
@@ -275,32 +276,32 @@ public function testCompileLabelWithLabelAndAttributes()
275276

276277
public function testCompileLabelWithLabelThatEvaluatesToNull()
277278
{
279+
if (class_exists(ConditionalTernary::class)) {
280+
$conditional = new ConditionalTernary(
281+
// if
282+
new ConstantExpression(true, 0),
283+
// then
284+
new ConstantExpression(null, 0),
285+
// else
286+
new ConstantExpression(null, 0),
287+
0
288+
);
289+
} else {
290+
$conditional = new ConditionalExpression(
291+
// if
292+
new ConstantExpression(true, 0),
293+
// then
294+
new ConstantExpression(null, 0),
295+
// else
296+
new ConstantExpression(null, 0),
297+
0
298+
);
299+
}
300+
278301
if (class_exists(Nodes::class)) {
279-
$arguments = new Nodes([
280-
new ContextVariable('form', 0),
281-
new ConditionalExpression(
282-
// if
283-
new ConstantExpression(true, 0),
284-
// then
285-
new ConstantExpression(null, 0),
286-
// else
287-
new ConstantExpression(null, 0),
288-
0
289-
),
290-
]);
302+
$arguments = new Nodes([new ContextVariable('form', 0), $conditional]);
291303
} else {
292-
$arguments = new Node([
293-
new NameExpression('form', 0),
294-
new ConditionalExpression(
295-
// if
296-
new ConstantExpression(true, 0),
297-
// then
298-
new ConstantExpression(null, 0),
299-
// else
300-
new ConstantExpression(null, 0),
301-
0
302-
),
303-
]);
304+
$arguments = new Node([new NameExpression('form', 0), $conditional]);
304305
}
305306

306307
$node = new SearchAndRenderBlockNode(new TwigFunction('form_label'), $arguments, 0);
@@ -322,18 +323,32 @@ public function testCompileLabelWithLabelThatEvaluatesToNull()
322323

323324
public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes()
324325
{
326+
if (class_exists(ConditionalTernary::class)) {
327+
$conditional = new ConditionalTernary(
328+
// if
329+
new ConstantExpression(true, 0),
330+
// then
331+
new ConstantExpression(null, 0),
332+
// else
333+
new ConstantExpression(null, 0),
334+
0
335+
);
336+
} else {
337+
$conditional = new ConditionalExpression(
338+
// if
339+
new ConstantExpression(true, 0),
340+
// then
341+
new ConstantExpression(null, 0),
342+
// else
343+
new ConstantExpression(null, 0),
344+
0
345+
);
346+
}
347+
325348
if (class_exists(Nodes::class)) {
326349
$arguments = new Nodes([
327350
new ContextVariable('form', 0),
328-
new ConditionalExpression(
329-
// if
330-
new ConstantExpression(true, 0),
331-
// then
332-
new ConstantExpression(null, 0),
333-
// else
334-
new ConstantExpression(null, 0),
335-
0
336-
),
351+
$conditional,
337352
new ArrayExpression([
338353
new ConstantExpression('foo', 0),
339354
new ConstantExpression('bar', 0),
@@ -344,12 +359,7 @@ public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes()
344359
} else {
345360
$arguments = new Node([
346361
new NameExpression('form', 0),
347-
new ConditionalExpression(
348-
new ConstantExpression(true, 0),
349-
new ConstantExpression(null, 0),
350-
new ConstantExpression(null, 0),
351-
0
352-
),
362+
$conditional,
353363
new ArrayExpression([
354364
new ConstantExpression('foo', 0),
355365
new ConstantExpression('bar', 0),

0 commit comments

Comments
 (0)