Skip to content

Commit 4f95295

Browse files
author
matheo
committed
add more test
1 parent 59b8f78 commit 4f95295

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
<button {{ attributes.merge({ class: 'btn' })|raw }}>
2-
{{ slot }}
3-
</button>
1+
<button {{ attributes.merge({ class: 'btn' })|raw }}>{{ slot }}</button>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div class='container warning'><twig:Button>{{ slot }}</twig:Button><p>Danger Zone</p></div>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<twig:DangerButton>Delete User</twig:DangerButton>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<twig:Alarm>
2+
You have a new message from @fabot
3+
<twig:slot name="footer">
4+
<twig:Button>
5+
Go to the message
6+
</twig:Button>
7+
</twig:slot>
8+
</twig:Alarm>

src/TwigComponent/tests/Integration/TwigComponentExtensionTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,19 @@ public function testRenderStaticComponentInSubFolder(): void
7474

7575
$this->assertStringContainsString('Hello from a sub folder', $output);
7676
}
77+
78+
public function testRenderNestedComponents(): void
79+
{
80+
$output = self::getContainer()->get(Environment::class)->render('slot/render_nested_component.html.twig');
81+
82+
$this->assertStringContainsString('You have a new message from @fabot', $output);
83+
$this->assertStringContainsString('Go to the message', $output);
84+
}
85+
86+
public function testPassDefaultSlotToChildComponents(): void
87+
{
88+
$output = self::getContainer()->get(Environment::class)->render('slot/pass_default_slot_to_child.html.twig');
89+
90+
$this->assertStringContainsString('<button class="btn">Delete User</button>', $output);
91+
}
7792
}

0 commit comments

Comments
 (0)