@@ -1264,6 +1264,12 @@ public function testGetPathInfo()
1264
1264
$ request ->initialize (array (), array (), array (), array (), array (), $ server );
1265
1265
1266
1266
$ 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 ());
1267
1273
}
1268
1274
1269
1275
public function testGetPreferredLanguage ()
@@ -1992,6 +1998,61 @@ public function methodCacheableProvider()
1992
1998
array ('CONNECT ' , false ),
1993
1999
);
1994
2000
}
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
+ }
1995
2056
}
1996
2057
1997
2058
class RequestContentProxy extends Request
0 commit comments