@@ -69,17 +69,17 @@ public function test_view_can_access_dynamic_slots(): void
6969 HTML,
7070 );
7171
72- $ html = $ this ->render (<<<'HTML '
72+ $ html = $ this ->render (<<<'HTML_WRAP '
7373 <x-test>
7474 <x-slot name="slot-php" language="PHP">PHP Body</x-slot>
7575 <x-slot name="slot-html" language="HTML">HTML Body</x-slot>
7676 </x-test>
77- HTML );
77+ HTML_WRAP );
7878
79- $ this ->assertStringEqualsStringIgnoringLineEndings (<<<'HTML '
79+ $ this ->assertStringEqualsStringIgnoringLineEndings (<<<'HTML_WRAP '
8080 <div><div>slot-php</div><div>PHP</div><div>PHP</div><div>PHP Body</div></div>
8181 <div><div>slot-html</div><div>HTML</div><div>HTML</div><div>HTML Body</div></div>
82- HTML , $ html );
82+ HTML_WRAP , $ html );
8383 }
8484
8585 public function test_dynamic_slots_are_cleaned_up (): void
@@ -155,15 +155,7 @@ public function test_nested_components(): void
155155 {
156156 $ this ->assertStringEqualsStringIgnoringLineEndings (
157157 expected: <<<'HTML'
158- <form action="#" method="post"><div><div><label for="a">a</label><input type="number" name="a" id="a" value></input></div>
159-
160-
161- </div>
162- <div><label for="b">b</label><input type="text" name="b" id="b" value></input></div>
163-
164-
165-
166- </form>
158+ <form action="#" method="post"><div><div><label for="a">a</label><input type="number" name="a" id="a" value></input></div></div><div><label for="b">b</label><input type="text" name="b" id="b" value></input></div></form>
167159 HTML,
168160 actual: $ this ->render (view (
169161 <<<'HTML'
@@ -290,8 +282,7 @@ public function test_with_passed_variable(): void
290282
291283 $ this ->assertStringEqualsStringIgnoringLineEndings (
292284 <<<HTML
293- <div>
294- test </div>
285+ <div>test</div>
295286 HTML ,
296287 $ rendered ,
297288 );
@@ -305,8 +296,7 @@ public function test_with_passed_data(): void
305296
306297 $ this ->assertStringEqualsStringIgnoringLineEndings (
307298 <<<HTML
308- <div>
309- test </div>
299+ <div>test</div>
310300 HTML ,
311301 $ rendered ,
312302 );
@@ -323,8 +313,7 @@ public function test_with_passed_php_data(): void
323313
324314 $ this ->assertStringEqualsStringIgnoringLineEndings (
325315 <<<HTML
326- <div>
327- TEST </div>
316+ <div>TEST</div>
328317 HTML ,
329318 $ rendered ,
330319 );
@@ -464,4 +453,33 @@ public static function view_components(): Generator
464453 '<div foo="fooValue" bar="barValue">body</div> ' ,
465454 ];
466455 }
456+
457+ public function test_full_html_document_as_component (): void
458+ {
459+ $ this ->registerViewComponent ('x-layout ' , <<<'HTML'
460+ <html lang="en">
461+ <head>
462+ <title>Tempest View</title>
463+ </head>
464+ <body>
465+ <x-slot />
466+ </body>
467+ </html>
468+ HTML);
469+
470+ $ html = $ this ->render (<<<'HTML'
471+ <x-layout>
472+ Hello World
473+ </x-layout>
474+ HTML);
475+
476+ $ this ->assertStringEqualsStringIgnoringLineEndings (<<<'HTML'
477+ <html lang="en"><head><title>Tempest View</title></head><body>
478+
479+ Hello World
480+
481+
482+ </body></html>
483+ HTML, $ html );
484+ }
467485}
0 commit comments