@@ -446,12 +446,14 @@ public function testRunRedirectionWithURI()
446446 /**
447447 * @see https://github.com/codeigniter4/CodeIgniter4/issues/3041
448448 */
449- public function testRunRedirectionWithURINotSet ()
449+ public function testRunRedirectionWithGET ()
450450 {
451451 $ _SERVER ['argv ' ] = ['index.php ' , 'example ' ];
452452 $ _SERVER ['argc ' ] = 2 ;
453453
454- $ _SERVER ['REQUEST_URI ' ] = '/example ' ;
454+ $ _SERVER ['REQUEST_URI ' ] = '/example ' ;
455+ $ _SERVER ['SERVER_PROTOCOL ' ] = 'HTTP/1.1 ' ;
456+ $ _SERVER ['REQUEST_METHOD ' ] = 'GET ' ;
455457
456458 // Inject mock router.
457459 $ routes = Services::routes ();
@@ -463,11 +465,37 @@ public function testRunRedirectionWithURINotSet()
463465 ob_start ();
464466 $ this ->codeigniter ->run ();
465467 ob_get_clean ();
468+
466469 $ response = $ this ->getPrivateProperty ($ this ->codeigniter , 'response ' );
467470 $ this ->assertSame ('http://example.com/pages/notset ' , $ response ->header ('Location ' )->getValue ());
471+ $ this ->assertSame (307 , $ response ->getStatusCode ());
472+ }
473+
474+ public function testRunRedirectionWithGETAndHTTPCode301 ()
475+ {
476+ $ _SERVER ['argv ' ] = ['index.php ' , 'example ' ];
477+ $ _SERVER ['argc ' ] = 2 ;
478+
479+ $ _SERVER ['REQUEST_URI ' ] = '/example ' ;
480+ $ _SERVER ['SERVER_PROTOCOL ' ] = 'HTTP/1.1 ' ;
481+ $ _SERVER ['REQUEST_METHOD ' ] = 'GET ' ;
482+
483+ // Inject mock router.
484+ $ routes = Services::routes ();
485+ $ routes ->addRedirect ('example ' , 'pages/notset ' , 301 );
486+
487+ $ router = Services::router ($ routes , Services::incomingrequest ());
488+ Services::injectMock ('router ' , $ router );
489+
490+ ob_start ();
491+ $ this ->codeigniter ->run ();
492+ ob_get_clean ();
493+
494+ $ response = $ this ->getPrivateProperty ($ this ->codeigniter , 'response ' );
495+ $ this ->assertSame (301 , $ response ->getStatusCode ());
468496 }
469497
470- public function testRunRedirectionWithHTTPCode303 ()
498+ public function testRunRedirectionWithPOSTAndHTTPCode301 ()
471499 {
472500 $ _SERVER ['argv ' ] = ['index.php ' , 'example ' ];
473501 $ _SERVER ['argc ' ] = 2 ;
0 commit comments