File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed
Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Tests \Tempest \Fixtures ;
6+
7+ use Tempest \View \Elements \ViewComponentElement ;
8+ use Tempest \View \ViewComponent ;
9+
10+ final readonly class DefaultSlotValueComponent implements ViewComponent
11+ {
12+ public static function getName (): string
13+ {
14+ return 'x-default-slot ' ;
15+ }
16+
17+ public function compile (ViewComponentElement $ element ): string
18+ {
19+ return <<<HTML
20+ <div>
21+ <x-slot>Default Value</x-slot>
22+ </div>
23+ HTML ;
24+ }
25+ }
Original file line number Diff line number Diff line change @@ -243,6 +243,31 @@ public function test_implicit_default_slot(): void
243243 );
244244 }
245245
246+ public function test_override_default_slot (): void
247+ {
248+ $ this ->assertStringEqualsStringIgnoringLineEndings (
249+ <<<'HTML'
250+ <div>Default Value</div>
251+ HTML,
252+ $ this ->render (
253+ <<<'HTML'
254+ <x-default-slot/>
255+ HTML,
256+ ),
257+ );
258+
259+ $ this ->assertStringEqualsStringIgnoringLineEndings (
260+ <<<'HTML'
261+ <div>Custom Value</div>
262+ HTML,
263+ $ this ->render (
264+ <<<'HTML'
265+ <x-default-slot>Custom Value</x-default-slot>
266+ HTML,
267+ ),
268+ );
269+ }
270+
246271 public function test_multiple_slots (): void
247272 {
248273 $ this ->assertSnippetsMatch (
You can’t perform that action at this time.
0 commit comments