@@ -483,6 +483,17 @@ public function testCanMatchFreshRoute(): void
483483 }
484484 }
485485
486+ public function testCanMatchRootRouteWhenUriHasNoPath (): void
487+ {
488+ $ route = Http::get ('/ ' );
489+
490+ $ _SERVER ['REQUEST_METHOD ' ] = Http::REQUEST_METHOD_GET ;
491+ $ _SERVER ['REQUEST_URI ' ] = 'https://example.com?x=1 ' ;
492+
493+ $ this ->assertSame ($ route , $ this ->http ->match (new Request ()));
494+ $ this ->assertSame ($ route , $ this ->http ->getRoute ());
495+ }
496+
486497 public function testCanRunRequest (): void
487498 {
488499 // Test head requests
@@ -556,6 +567,31 @@ public function testWildcardRoute(): void
556567 $ _SERVER ['REQUEST_URI ' ] = $ uri ;
557568 }
558569
570+ public function testWildcardRouteWhenUriHasNoPath (): void
571+ {
572+ $ method = $ _SERVER ['REQUEST_METHOD ' ] ?? null ;
573+ $ uri = $ _SERVER ['REQUEST_URI ' ] ?? null ;
574+
575+ $ _SERVER ['REQUEST_METHOD ' ] = 'GET ' ;
576+ $ _SERVER ['REQUEST_URI ' ] = 'https://example.com?x=1 ' ;
577+
578+ Http::wildcard ()
579+ ->inject ('response ' )
580+ ->action (function ($ response ) {
581+ $ response ->send ('HELLO ' );
582+ });
583+
584+ \ob_start ();
585+ @$ this ->http ->run (new Request (), new Response ());
586+ $ result = \ob_get_contents ();
587+ \ob_end_clean ();
588+
589+ $ _SERVER ['REQUEST_METHOD ' ] = $ method ;
590+ $ _SERVER ['REQUEST_URI ' ] = $ uri ;
591+
592+ $ this ->assertEquals ('HELLO ' , $ result );
593+ }
594+
559595 public function testCallableStringParametersNotExecuted (): void
560596 {
561597 // Test that callable strings (like function names) are not executed
0 commit comments