Skip to content

Commit c67f5b7

Browse files
committed
Reproduce InteractsWithTwigComponents not being able to render blocks when variable scope is limited in tests
1 parent 27bf7f8 commit c67f5b7

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\UX\TwigComponent\Tests\Fixtures\Component;
13+
14+
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
15+
16+
/**
17+
* @author Kevin Bond <kevinbond@gmail.com>
18+
*/
19+
#[AsTwigComponent]
20+
final class WithSlotsAndLimitedScope
21+
{
22+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div>
2+
{% with { outerScope } only %}
3+
{% block content %}{% endblock %}
4+
{% block slot1 %}{% endblock %}
5+
{% block slot2 %}{% endblock %}
6+
{% endwith %}
7+
</div>

src/TwigComponent/tests/Integration/ComponentFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ public function testCannotGetConfigByNameForNonRegisteredComponent()
261261
* @testWith ["tabl", "Unknown component \"tabl\". Did you mean this: \"table\"?"]
262262
* ["Basic", "Unknown component \"Basic\". Did you mean this: \"BasicComponent\"?"]
263263
* ["basic", "Unknown component \"basic\". Did you mean this: \"BasicComponent\"?"]
264-
* ["with", "Unknown component \"with\". Did you mean one of these: \"with_attributes\", \"with_exposed_variables\", \"WithSlots\"?"]
264+
* ["with", "Unknown component \"with\". Did you mean one of these: \"with_attributes\", \"with_exposed_variables\", \"WithSlots\", \"WithSlotsAndLimitedScope\"?"]
265265
* ["anonAnon", "Unknown component \"anonAnon\". And no matching anonymous component template was found."]
266266
*/
267267
public function testCannotGetInvalidComponent(string $name, string $expectedExceptionMessage)

src/TwigComponent/tests/Integration/Test/InteractsWithTwigComponentsTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\UX\TwigComponent\Test\InteractsWithTwigComponents;
1616
use Symfony\UX\TwigComponent\Tests\Fixtures\Component\ComponentA;
1717
use Symfony\UX\TwigComponent\Tests\Fixtures\Component\WithSlots;
18+
use Symfony\UX\TwigComponent\Tests\Fixtures\Component\WithSlotsAndLimitedScope;
1819
use Symfony\UX\TwigComponent\Tests\Fixtures\Service\ServiceA;
1920

2021
final class InteractsWithTwigComponentsTest extends KernelTestCase
@@ -87,5 +88,7 @@ public static function withSlotsNameProvider(): iterable
8788
{
8889
yield ['WithSlots'];
8990
yield [WithSlots::class];
91+
yield ['WithSlotsAndLimitedScope'];
92+
yield [WithSlotsAndLimitedScope::class];
9093
}
9194
}

0 commit comments

Comments
 (0)