@@ -1264,6 +1264,12 @@ public function testGetPathInfo()
12641264 $ request ->initialize (array (), array (), array (), array (), array (), $ server );
12651265
12661266 $ this ->assertEquals ('/path%20test/info ' , $ request ->getPathInfo ());
1267+
1268+ $ server = array ();
1269+ $ server ['REQUEST_URI ' ] = '?a=b ' ;
1270+ $ request ->initialize (array (), array (), array (), array (), array (), $ server );
1271+
1272+ $ this ->assertEquals ('/ ' , $ request ->getPathInfo ());
12671273 }
12681274
12691275 public function testGetPreferredLanguage ()
@@ -1992,6 +1998,61 @@ public function methodCacheableProvider()
19921998 array ('CONNECT ' , false ),
19931999 );
19942000 }
2001+
2002+ public function nonstandardRequestsData ()
2003+ {
2004+ return array (
2005+ array ('' , '' , '/ ' , 'http://host:8080/ ' , '' ),
2006+ array ('/ ' , '' , '/ ' , 'http://host:8080/ ' , '' ),
2007+
2008+ array ('hello/app.php/x ' , '' , '/x ' , 'http://host:8080/hello/app.php/x ' , '/hello ' , '/hello/app.php ' ),
2009+ array ('/hello/app.php/x ' , '' , '/x ' , 'http://host:8080/hello/app.php/x ' , '/hello ' , '/hello/app.php ' ),
2010+
2011+ array ('' , 'a=b ' , '/ ' , 'http://host:8080/?a=b ' ),
2012+ array ('?a=b ' , 'a=b ' , '/ ' , 'http://host:8080/?a=b ' ),
2013+ array ('/?a=b ' , 'a=b ' , '/ ' , 'http://host:8080/?a=b ' ),
2014+
2015+ array ('x ' , 'a=b ' , '/x ' , 'http://host:8080/x?a=b ' ),
2016+ array ('x?a=b ' , 'a=b ' , '/x ' , 'http://host:8080/x?a=b ' ),
2017+ array ('/x?a=b ' , 'a=b ' , '/x ' , 'http://host:8080/x?a=b ' ),
2018+
2019+ array ('hello/x ' , '' , '/x ' , 'http://host:8080/hello/x ' , '/hello ' ),
2020+ array ('/hello/x ' , '' , '/x ' , 'http://host:8080/hello/x ' , '/hello ' ),
2021+
2022+ array ('hello/app.php/x ' , 'a=b ' , '/x ' , 'http://host:8080/hello/app.php/x?a=b ' , '/hello ' , '/hello/app.php ' ),
2023+ array ('hello/app.php/x?a=b ' , 'a=b ' , '/x ' , 'http://host:8080/hello/app.php/x?a=b ' , '/hello ' , '/hello/app.php ' ),
2024+ array ('/hello/app.php/x?a=b ' , 'a=b ' , '/x ' , 'http://host:8080/hello/app.php/x?a=b ' , '/hello ' , '/hello/app.php ' ),
2025+ );
2026+ }
2027+
2028+ /**
2029+ * @dataProvider nonstandardRequestsData
2030+ */
2031+ public function testNonstandardRequests ($ requestUri , $ queryString , $ expectedPathInfo , $ expectedUri , $ expectedBasePath = '' , $ expectedBaseUrl = null )
2032+ {
2033+ if (null === $ expectedBaseUrl ) {
2034+ $ expectedBaseUrl = $ expectedBasePath ;
2035+ }
2036+
2037+ $ server = array (
2038+ 'HTTP_HOST ' => 'host:8080 ' ,
2039+ 'SERVER_PORT ' => '8080 ' ,
2040+ 'QUERY_STRING ' => $ queryString ,
2041+ 'PHP_SELF ' => '/hello/app.php ' ,
2042+ 'SCRIPT_FILENAME ' => '/some/path/app.php ' ,
2043+ 'REQUEST_URI ' => $ requestUri ,
2044+ );
2045+
2046+ $ request = new Request (array (), array (), array (), array (), array (), $ server );
2047+
2048+ $ this ->assertEquals ($ expectedPathInfo , $ request ->getPathInfo ());
2049+ $ this ->assertEquals ($ expectedUri , $ request ->getUri ());
2050+ $ this ->assertEquals ($ queryString , $ request ->getQueryString ());
2051+ $ this ->assertEquals (8080 , $ request ->getPort ());
2052+ $ this ->assertEquals ('host:8080 ' , $ request ->getHttpHost ());
2053+ $ this ->assertEquals ($ expectedBaseUrl , $ request ->getBaseUrl ());
2054+ $ this ->assertEquals ($ expectedBasePath , $ request ->getBasePath ());
2055+ }
19952056}
19962057
19972058class RequestContentProxy extends Request
0 commit comments