|
15 | 15 | use Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode; |
16 | 16 | use Twig\Compiler; |
17 | 17 | use Twig\Environment; |
| 18 | +use Twig\Extension\CoreExtension; |
18 | 19 | use Twig\Loader\LoaderInterface; |
19 | 20 | use Twig\Node\Expression\ArrayExpression; |
20 | 21 | use Twig\Node\Expression\ConditionalExpression; |
@@ -224,13 +225,11 @@ public function testCompileLabelWithLabelThatEvaluatesToNull() |
224 | 225 | // "label" => null must not be included in the output! |
225 | 226 | // Otherwise the default label is overwritten with null. |
226 | 227 | // https://github.com/symfony/symfony/issues/5029 |
227 | | - $this->assertEquals( |
228 | | - sprintf( |
229 | | - '$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', (twig_test_empty($_label_ = ((true) ? (null) : (null))) ? [] : ["label" => $_label_]))', |
230 | | - $this->getVariableGetter('form') |
231 | | - ), |
232 | | - trim($compiler->compile($node)->getSource()) |
233 | | - ); |
| 228 | + if (method_exists(CoreExtension::class, 'testEmpty')) { |
| 229 | + $this->assertEquals(sprintf('$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', (Twig\Extension\CoreExtension::testEmpty($_label_ = ((true) ? (null) : (null))) ? [] : ["label" => $_label_]))', $this->getVariableGetter('form')), trim($compiler->compile($node)->getSource())); |
| 230 | + } else { |
| 231 | + $this->assertEquals(sprintf('$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', (twig_test_empty($_label_ = ((true) ? (null) : (null))) ? [] : ["label" => $_label_]))', $this->getVariableGetter('form')), trim($compiler->compile($node)->getSource())); |
| 232 | + } |
234 | 233 | } |
235 | 234 |
|
236 | 235 | public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes() |
@@ -261,13 +260,11 @@ public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes() |
261 | 260 | // "label" => null must not be included in the output! |
262 | 261 | // Otherwise the default label is overwritten with null. |
263 | 262 | // https://github.com/symfony/symfony/issues/5029 |
264 | | - $this->assertEquals( |
265 | | - sprintf( |
266 | | - '$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', ["foo" => "bar", "label" => "value in attributes"] + (twig_test_empty($_label_ = ((true) ? (null) : (null))) ? [] : ["label" => $_label_]))', |
267 | | - $this->getVariableGetter('form') |
268 | | - ), |
269 | | - trim($compiler->compile($node)->getSource()) |
270 | | - ); |
| 263 | + if (method_exists(CoreExtension::class, 'testEmpty')) { |
| 264 | + $this->assertEquals(sprintf('$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', ["foo" => "bar", "label" => "value in attributes"] + (Twig\Extension\CoreExtension::testEmpty($_label_ = ((true) ? (null) : (null))) ? [] : ["label" => $_label_]))', $this->getVariableGetter('form')), trim($compiler->compile($node)->getSource())); |
| 265 | + } else { |
| 266 | + $this->assertEquals(sprintf('$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', ["foo" => "bar", "label" => "value in attributes"] + (twig_test_empty($_label_ = ((true) ? (null) : (null))) ? [] : ["label" => $_label_]))', $this->getVariableGetter('form')), trim($compiler->compile($node)->getSource())); |
| 267 | + } |
271 | 268 | } |
272 | 269 |
|
273 | 270 | protected function getVariableGetter($name) |
|
0 commit comments