Skip to content

Commit d4bc871

Browse files
committed
add tests
1 parent 6ed014f commit d4bc871

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<twig:Alert size='md'>
2+
<twig:Icon/>
3+
</twig:Alert>

src/TwigComponent/tests/Fixtures/templates/components/Alert.html.twig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@
3131
}) %}
3232

3333
<div class="{{ alert.apply({color, size}, attributes.render('class'), 'flex p-4') }}">
34-
...
34+
{% block content %}
35+
{% endblock %}
3536
</div>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{% props size = null %}
2+
3+
<p>I am an icon</p>
4+
{% if size is not null %}
5+
<p>I am {{ size }}</p>
6+
{% endif %}

src/TwigComponent/tests/Integration/ComponentExtensionTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,14 @@ public function testComponentWithConflictBetweenPropsFromTemplateAndClass(): voi
366366
self::getContainer()->get(Environment::class)->render('component_with_conflict_between_props_from_template_and_class.html.twig');
367367
}
368368

369+
public function testAnonymousComponentWithPropsOverwriteParentsProps(): void
370+
{
371+
$output = self::getContainer()->get(Environment::class)->render('anonymous_component_with_props_overwrite_parents_props.html.twig');
372+
373+
$this->assertStringContainsString('I am an icon', $output);
374+
$this->assertStringNotContainsString('I am md', $output);
375+
}
376+
369377
private function renderComponent(string $name, array $data = []): string
370378
{
371379
return self::getContainer()->get(Environment::class)->render('render_component.html.twig', [

0 commit comments

Comments
 (0)