11<?php
22
3- namespace MarcoRieser \Livewire \Tests \Hooks ;
3+ namespace MarcoRieser \Livewire \Tests \Tags ;
44
55use Livewire \Component ;
66use Livewire \Livewire ;
1010use PHPUnit \Framework \Attributes \Test ;
1111use Statamic \Facades \Collection ;
1212use Statamic \Facades \Entry ;
13+ use Statamic \Facades \Parse ;
1314use Statamic \Testing \Concerns \PreventsSavingStacheItemsToDisk ;
1415
1516class LivewireTest extends TestCase
1617{
1718 use CanManipulateAddonConfig;
1819 use PreventsSavingStacheItemsToDisk;
1920
21+ #[Test]
22+ #[DefineEnvironment('disableSynthesizers ' )]
23+ public function parameters_are_converted_to_an_array_when_passed_to_a_component_if_synthesizers_are_disabled ()
24+ {
25+ $ component = new class extends Component
26+ {
27+ public \Statamic \Contracts \Entries \Entry $ entry ;
28+
29+ public function render ()
30+ {
31+ return '<div></div> ' ;
32+ }
33+ };
34+
35+ $ component ->setName ('test ' );
36+
37+ $ entry = Entry::find ('1 ' );
38+
39+ Livewire::expects ('mount ' )->with ('test ' , ['entry ' => $ entry ->toArray ()], null );
40+
41+ Parse::template ('{{ livewire:test :entry="entry" /}} ' , ['entry ' => $ entry ]);
42+ }
43+
2044 #[Test]
2145 #[DefineEnvironment('enableSynthesizers ' )]
22- public function parameters_keep_their_type_when_passed_to_a_component ()
46+ public function parameters_keep_their_type_when_passed_to_a_component_if_synthesizers_are_enabled ()
2347 {
2448 $ component = new class extends Component
2549 {
@@ -31,11 +55,13 @@ public function render()
3155 }
3256 };
3357
58+ $ component ->setName ('test ' );
59+
3460 $ entry = Entry::find ('1 ' );
3561
36- $ testable = Livewire::test ( $ component , ['entry ' => $ entry ]);
62+ Livewire::expects ( ' mount ' )-> with ( ' test ' , ['entry ' => $ entry ], null );
3763
38- $ testable -> assertSetStrict ( ' entry ' , $ entry );
64+ Parse:: template ( ' {{ livewire:test : entry="entry" /}} ' , [ ' entry ' => $ entry] );
3965 }
4066
4167 protected function setUp (): void
0 commit comments