Skip to content

Commit 142b273

Browse files
committed
add test for rendering embedded components as live
1 parent 31c09f3 commit 142b273

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{% component component2 %}
2+
{% endcomponent %}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Symfony\UX\LiveComponent\Tests\Integration\EventListener;
4+
5+
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
6+
use Symfony\UX\TwigComponent\EventListener\PreRenderEvent;
7+
use Twig\Environment;
8+
use Twig\Error\RuntimeError;
9+
10+
/**
11+
* @author Kevin Bond <[email protected]>
12+
*/
13+
final class AddLiveAttributesSubscriberTest extends KernelTestCase
14+
{
15+
public function testCannotUseEmbeddedComponentAsLive(): void
16+
{
17+
if (!method_exists(PreRenderEvent::class, 'isEmbedded')) {
18+
$this->markTestSkipped('Embedded components not available.');
19+
}
20+
21+
$twig = self::getContainer()->get(Environment::class);
22+
23+
$this->expectException(RuntimeError::class);
24+
$this->expectExceptionMessage('Embedded components cannot be live.');
25+
26+
$twig->render('render_embedded.html.twig');
27+
}
28+
}

0 commit comments

Comments
 (0)