1414use Symfony \Bundle \FrameworkBundle \Test \KernelTestCase ;
1515use Symfony \UX \TwigComponent \Test \InteractsWithTwigComponents ;
1616use Symfony \UX \TwigComponent \Tests \Fixtures \Component \ComponentA ;
17+ use Symfony \UX \TwigComponent \Tests \Fixtures \Component \WithSlots ;
1718use Symfony \UX \TwigComponent \Tests \Fixtures \Service \ServiceA ;
1819
1920final class InteractsWithTwigComponentsTest extends KernelTestCase
2021{
2122 use InteractsWithTwigComponents;
2223
23- public function testCanMountComponent (): void
24+ /**
25+ * @dataProvider componentANameProvider
26+ */
27+ public function testCanMountComponent (string $ name ): void
2428 {
25- $ component = $ this ->mountTwigComponent (' component_a ' , [
29+ $ component = $ this ->mountTwigComponent ($ name , [
2630 'propA ' => 'prop a value ' ,
2731 'propB ' => 'prop b value ' ,
2832 ]);
@@ -33,9 +37,12 @@ public function testCanMountComponent(): void
3337 $ this ->assertSame ('prop b value ' , $ component ->getPropB ());
3438 }
3539
36- public function testCanRenderComponent (): void
40+ /**
41+ * @dataProvider componentANameProvider
42+ */
43+ public function testCanRenderComponent (string $ name ): void
3744 {
38- $ rendered = $ this ->renderTwigComponent (' component_a ' , [
45+ $ rendered = $ this ->renderTwigComponent ($ name , [
3946 'propA ' => 'prop a value ' ,
4047 'propB ' => 'prop b value ' ,
4148 ]);
@@ -45,10 +52,13 @@ public function testCanRenderComponent(): void
4552 $ this ->assertStringContainsString ('service: service a value ' , $ rendered );
4653 }
4754
48- public function testCanRenderComponentWithSlots (): void
55+ /**
56+ * @dataProvider withSlotsNameProvider
57+ */
58+ public function testCanRenderComponentWithSlots (string $ name ): void
4959 {
5060 $ rendered = $ this ->renderTwigComponent (
51- name: ' WithSlots ' ,
61+ name: $ name ,
5262 content: '<p>some content</p> ' ,
5363 blocks: [
5464 'slot1 ' => '<p>some slot1 content</p> ' ,
@@ -65,4 +75,16 @@ public function testCanRenderComponentWithSlots(): void
6575 $ this ->assertStringContainsString ('propB: prop b value ' , $ rendered );
6676 $ this ->assertStringContainsString ('service: service a value ' , $ rendered );
6777 }
78+
79+ public static function componentANameProvider (): iterable
80+ {
81+ yield ['component_a ' ];
82+ yield [ComponentA::class];
83+ }
84+
85+ public static function withSlotsNameProvider (): iterable
86+ {
87+ yield ['WithSlots ' ];
88+ yield [WithSlots::class];
89+ }
6890}
0 commit comments