@@ -193,11 +193,10 @@ public function test_shared_data_can_be_shared_from_anywhere(): void
193193
194194 public function test_can_flush_shared_data (): void
195195 {
196- get (Inertia::class)
197- ->share (
198- key: 'foo ' ,
199- value: 'bar ' ,
200- );
196+ get (Inertia::class)->share (
197+ key: 'foo ' ,
198+ value: 'bar ' ,
199+ );
201200
202201 static ::assertArrayHasKey (
203202 key: 'foo ' ,
@@ -245,26 +244,35 @@ public function test_mergeable_props_can_be_merged(): void
245244 );
246245 }
247246
248- // public function test_will_accept_arrayabe_props()
249- // {
250- // Route::middleware([StartSession::class, ExampleMiddleware::class])->get('/', function () {
251- // Inertia::share('foo', 'bar');
252- // return Inertia::render('User/Edit', new class() implements Arrayable {
253- // public function toArray()
254- // {
255- // return [
256- // 'foo' => 'bar',
257- // ];
258- // }
259- // });
260- // });
261- // $response = $this->http->get('/', ['X-Inertia' => 'true']);
262- // $response->assertSuccessful();
263- // $response->assertJson([
264- // 'component' => 'User/Edit',
265- // 'props' => [
266- // 'foo' => 'bar',
267- // ],
268- // ]);
269- // }
247+ public function test_array_helper_props_can_be_resolved (): void
248+ {
249+ $ version = get (Inertia::class)->version ;
250+
251+ $ response = $ this ->http ->get (uri ([TestController::class, 'testAllSortsOfProps ' ]), headers: [
252+ Header::INERTIA => 'true ' ,
253+ Header::VERSION => $ version ,
254+ Header::PARTIAL_COMPONENT => 'User/Edit ' ,
255+ Header::PARTIAL_ONLY => 'optional,defer ' ,
256+ ]);
257+
258+ $ response ->assertOk ();
259+ static ::assertSame (
260+ expected: [
261+ 'component ' => 'User/Edit ' ,
262+ 'props ' => [
263+ 'user ' => null ,
264+ 'errors ' => [],
265+ 'shared ' => [1 , 2 , 3 ],
266+ 'always ' => ['always-1 ' , 'always-2 ' ],
267+ 'optional ' => ['optional-1 ' , 'optional-2 ' ],
268+ 'defer ' => ['defer-1 ' , 'defer-2 ' ],
269+ ],
270+ 'url ' => uri ([TestController::class, 'testAllSortsOfProps ' ]),
271+ 'version ' => $ version ,
272+ 'clearHistory ' => false ,
273+ 'encryptHistory ' => false ,
274+ ],
275+ actual: $ response ->body ->jsonSerialize (),
276+ );
277+ }
270278}
0 commit comments