@@ -146,6 +146,66 @@ public function test_shared_data_can_be_shared_from_anywhere(): void
146146 ]);
147147 }
148148
149+ public function test_dot_props_are_merged_from_shared (): void
150+ {
151+ Route::middleware ([StartSession::class, ExampleMiddleware::class])->get ('/ ' , function () {
152+ Inertia::share ('auth.user ' , [
153+ 'name ' => 'Jonathan ' ,
154+ ]);
155+
156+ return Inertia::render ('User/Edit ' , [
157+ 'auth.user.can.create_group ' => false ,
158+ ]);
159+ });
160+
161+ $ response = $ this ->withoutExceptionHandling ()->get ('/ ' , ['X-Inertia ' => 'true ' ]);
162+
163+ $ response ->assertSuccessful ();
164+ $ response ->assertJson ([
165+ 'component ' => 'User/Edit ' ,
166+ 'props ' => [
167+ 'auth ' => [
168+ 'user ' => [
169+ 'name ' => 'Jonathan ' ,
170+ 'can ' => [
171+ 'create_group ' => false ,
172+ ],
173+ ],
174+ ],
175+ ],
176+ ]);
177+ }
178+
179+ public function test_dot_props_with_callbacks_are_merged_from_shared (): void
180+ {
181+ Route::middleware ([StartSession::class, ExampleMiddleware::class])->get ('/ ' , function () {
182+ Inertia::share ('auth.user ' , fn () => [
183+ 'name ' => 'Jonathan ' ,
184+ ]);
185+
186+ return Inertia::render ('User/Edit ' , [
187+ 'auth.user.can.create_group ' => false ,
188+ ]);
189+ });
190+
191+ $ response = $ this ->withoutExceptionHandling ()->get ('/ ' , ['X-Inertia ' => 'true ' ]);
192+
193+ $ response ->assertSuccessful ();
194+ $ response ->assertJson ([
195+ 'component ' => 'User/Edit ' ,
196+ 'props ' => [
197+ 'auth ' => [
198+ 'user ' => [
199+ 'name ' => 'Jonathan ' ,
200+ 'can ' => [
201+ 'create_group ' => false ,
202+ ],
203+ ],
204+ ],
205+ ],
206+ ]);
207+ }
208+
149209 public function test_can_flush_shared_data (): void
150210 {
151211 Inertia::share ('foo ' , 'bar ' );
0 commit comments