@@ -608,6 +608,58 @@ public function testCanMatchRoute(string $method, string $path, ?string $url = n
608608 $ this ->assertEquals ($ expected , $ route );
609609 }
610610
611+ public function testMatchWithNullPath (): void
612+ {
613+ // Create a route for root path
614+ $ expected = Http::get ('/ ' );
615+
616+ // Test case where parse_url returns null (malformed URL)
617+ $ _SERVER ['REQUEST_METHOD ' ] = 'GET ' ;
618+ $ _SERVER ['REQUEST_URI ' ] = '?param=1 ' ; // This will cause parse_url to return null for PATH component
619+
620+ $ matched = $ this ->http ->match (new Request ());
621+ $ this ->assertEquals ($ expected , $ matched );
622+ }
623+
624+ public function testMatchWithEmptyPath (): void
625+ {
626+ // Create a route for root path
627+ $ expected = Http::get ('/ ' );
628+
629+ // Test case where URI has no path component
630+ $ _SERVER ['REQUEST_METHOD ' ] = 'GET ' ;
631+ $ _SERVER ['REQUEST_URI ' ] = 'https://example.com ' ; // No path component
632+
633+ $ matched = $ this ->http ->match (new Request ());
634+ $ this ->assertEquals ($ expected , $ matched );
635+ }
636+
637+ public function testMatchWithMalformedURL (): void
638+ {
639+ // Create a route for root path
640+ $ expected = Http::get ('/ ' );
641+
642+ // Test case where parse_url returns false (severely malformed URL)
643+ $ _SERVER ['REQUEST_METHOD ' ] = 'GET ' ;
644+ $ _SERVER ['REQUEST_URI ' ] = '#fragment ' ; // Malformed scheme
645+
646+ $ matched = $ this ->http ->match (new Request ());
647+ $ this ->assertEquals ($ expected , $ matched );
648+ }
649+
650+ public function testMatchWithOnlyQueryString (): void
651+ {
652+ // Create a route for root path
653+ $ expected = Http::get ('/ ' );
654+
655+ // Test case where URI has only query string (no path)
656+ $ _SERVER ['REQUEST_METHOD ' ] = 'GET ' ;
657+ $ _SERVER ['REQUEST_URI ' ] = '?param=value ' ; // Only query string, no path
658+
659+ $ matched = $ this ->http ->match (new Request ());
660+ $ this ->assertEquals ($ expected , $ matched );
661+ }
662+
611663 public function testNoMismatchRoute (): void
612664 {
613665 $ requests = [
0 commit comments