@@ -221,7 +221,7 @@ public function testCanExecuteRoute(): void
221221 ->param ('x ' , 'x-def ' , new Text (1 , min: 0 ), 'x param ' , false )
222222 ->param ('y ' , 'y-def ' , new Text (1 , min: 0 ), 'y param ' , false )
223223 ->action (function ($ x , $ y ) {
224- echo $ x . '- ' , $ y ;
224+ echo $ x . '- ' . $ y ;
225225 });
226226
227227 \ob_start ();
@@ -467,7 +467,7 @@ public function providerRouteMatching(): array
467467 /**
468468 * @dataProvider providerRouteMatching
469469 */
470- public function testCanMatchRoute (string $ method , string $ path , string $ url = null ): void
470+ public function testCanMatchRoute (string $ method , string $ path , ? string $ url = null ): void
471471 {
472472 $ url ??= $ path ;
473473 $ expected = null ;
@@ -497,6 +497,58 @@ public function testCanMatchRoute(string $method, string $path, string $url = nu
497497 $ this ->assertEquals ($ expected , $ this ->app ->getRoute ());
498498 }
499499
500+ public function testMatchWithNullPath (): void
501+ {
502+ // Create a route for root path
503+ $ expected = App::get ('/ ' );
504+
505+ // Test case where parse_url returns null (malformed URL)
506+ $ _SERVER ['REQUEST_METHOD ' ] = 'GET ' ;
507+ $ _SERVER ['REQUEST_URI ' ] = '?param=1 ' ; // This will cause parse_url to return null for PATH component
508+
509+ $ matched = $ this ->app ->match (new Request ());
510+ $ this ->assertEquals ($ expected , $ matched );
511+ }
512+
513+ public function testMatchWithEmptyPath (): void
514+ {
515+ // Create a route for root path
516+ $ expected = App::get ('/ ' );
517+
518+ // Test case where URI has no path component
519+ $ _SERVER ['REQUEST_METHOD ' ] = 'GET ' ;
520+ $ _SERVER ['REQUEST_URI ' ] = 'https://example.com ' ; // No path component
521+
522+ $ matched = $ this ->app ->match (new Request ());
523+ $ this ->assertEquals ($ expected , $ matched );
524+ }
525+
526+ public function testMatchWithMalformedURL (): void
527+ {
528+ // Create a route for root path
529+ $ expected = App::get ('/ ' );
530+
531+ // Test case where parse_url returns false (severely malformed URL)
532+ $ _SERVER ['REQUEST_METHOD ' ] = 'GET ' ;
533+ $ _SERVER ['REQUEST_URI ' ] = '#fragment ' ; // Malformed scheme
534+
535+ $ matched = $ this ->app ->match (new Request ());
536+ $ this ->assertEquals ($ expected , $ matched );
537+ }
538+
539+ public function testMatchWithOnlyQueryString (): void
540+ {
541+ // Create a route for root path
542+ $ expected = App::get ('/ ' );
543+
544+ // Test case where URI has only query string (no path)
545+ $ _SERVER ['REQUEST_METHOD ' ] = 'GET ' ;
546+ $ _SERVER ['REQUEST_URI ' ] = '?param=value ' ; // Only query string, no path
547+
548+ $ matched = $ this ->app ->match (new Request ());
549+ $ this ->assertEquals ($ expected , $ matched );
550+ }
551+
500552 public function testNoMismatchRoute (): void
501553 {
502554 $ requests = [
0 commit comments