@@ -239,6 +239,40 @@ public function test_validation_errors_are_scoped_to_error_bag_header(): void
239239 $ this ->withoutExceptionHandling ()->get ('/ ' , ['X-Inertia-Error-Bag ' => 'example ' ]);
240240 }
241241
242+ public function test_route_params_are_registered_as_of_default (): void
243+ {
244+ Route::middleware ([StartSession::class, ExampleMiddleware::class])->get ('/ ' , function () {
245+ $ this ->assertInstanceOf (AlwaysProp::class, Inertia::getShared ('routeParams ' ));
246+ });
247+
248+ $ this ->withoutExceptionHandling ()->get ('/ ' );
249+ }
250+
251+ public function test_route_params_can_be_empty (): void
252+ {
253+ Route::middleware ([StartSession::class, ExampleMiddleware::class])->get ('/ ' , function () {
254+ $ routeParams = Inertia::getShared ('routeParams ' )();
255+
256+ $ this ->assertIsObject ($ routeParams );
257+ $ this ->assertEmpty (get_object_vars ($ routeParams ));
258+ });
259+
260+ $ this ->withoutExceptionHandling ()->get ('/ ' );
261+ }
262+
263+ public function test_route_params_are_returned_in_the_correct_format (): void
264+ {
265+ Route::middleware ([StartSession::class, ExampleMiddleware::class])
266+ ->get ('/{number}/{string} ' , function () {
267+ $ routeParams = Inertia::getShared ('routeParams ' )();
268+ $ this ->assertIsObject ($ routeParams );
269+ $ this ->assertSame ('1 ' , $ routeParams ->number );
270+ $ this ->assertSame ('john ' , $ routeParams ->string );
271+ });
272+
273+ $ this ->withoutExceptionHandling ()->get ('/1/john ' );
274+ }
275+
242276 public function test_middleware_can_change_the_root_view_via_a_property (): void
243277 {
244278 $ this ->prepareMockEndpoint (null , [], new class extends Middleware
0 commit comments