@@ -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 ()
@@ -2041,6 +2047,61 @@ public function methodCacheableProvider()
2041
2047
array ('CONNECT ' , false ),
2042
2048
);
2043
2049
}
2050
+
2051
+ public function nonstandardRequestsData ()
2052
+ {
2053
+ return array (
2054
+ array ('' , '' , '/ ' , 'http://host:8080/ ' , '' ),
2055
+ array ('/ ' , '' , '/ ' , 'http://host:8080/ ' , '' ),
2056
+
2057
+ array ('hello/app.php/x ' , '' , '/x ' , 'http://host:8080/hello/app.php/x ' , '/hello ' , '/hello/app.php ' ),
2058
+ array ('/hello/app.php/x ' , '' , '/x ' , 'http://host:8080/hello/app.php/x ' , '/hello ' , '/hello/app.php ' ),
2059
+
2060
+ array ('' , 'a=b ' , '/ ' , 'http://host:8080/?a=b ' ),
2061
+ array ('?a=b ' , 'a=b ' , '/ ' , 'http://host:8080/?a=b ' ),
2062
+ array ('/?a=b ' , 'a=b ' , '/ ' , 'http://host:8080/?a=b ' ),
2063
+
2064
+ array ('x ' , 'a=b ' , '/x ' , 'http://host:8080/x?a=b ' ),
2065
+ array ('x?a=b ' , 'a=b ' , '/x ' , 'http://host:8080/x?a=b ' ),
2066
+ array ('/x?a=b ' , 'a=b ' , '/x ' , 'http://host:8080/x?a=b ' ),
2067
+
2068
+ array ('hello/x ' , '' , '/x ' , 'http://host:8080/hello/x ' , '/hello ' ),
2069
+ array ('/hello/x ' , '' , '/x ' , 'http://host:8080/hello/x ' , '/hello ' ),
2070
+
2071
+ array ('hello/app.php/x ' , 'a=b ' , '/x ' , 'http://host:8080/hello/app.php/x?a=b ' , '/hello ' , '/hello/app.php ' ),
2072
+ array ('hello/app.php/x?a=b ' , 'a=b ' , '/x ' , 'http://host:8080/hello/app.php/x?a=b ' , '/hello ' , '/hello/app.php ' ),
2073
+ array ('/hello/app.php/x?a=b ' , 'a=b ' , '/x ' , 'http://host:8080/hello/app.php/x?a=b ' , '/hello ' , '/hello/app.php ' ),
2074
+ );
2075
+ }
2076
+
2077
+ /**
2078
+ * @dataProvider nonstandardRequestsData
2079
+ */
2080
+ public function testNonstandardRequests ($ requestUri , $ queryString , $ expectedPathInfo , $ expectedUri , $ expectedBasePath = '' , $ expectedBaseUrl = null )
2081
+ {
2082
+ if (null === $ expectedBaseUrl ) {
2083
+ $ expectedBaseUrl = $ expectedBasePath ;
2084
+ }
2085
+
2086
+ $ server = array (
2087
+ 'HTTP_HOST ' => 'host:8080 ' ,
2088
+ 'SERVER_PORT ' => '8080 ' ,
2089
+ 'QUERY_STRING ' => $ queryString ,
2090
+ 'PHP_SELF ' => '/hello/app.php ' ,
2091
+ 'SCRIPT_FILENAME ' => '/some/path/app.php ' ,
2092
+ 'REQUEST_URI ' => $ requestUri ,
2093
+ );
2094
+
2095
+ $ request = new Request (array (), array (), array (), array (), array (), $ server );
2096
+
2097
+ $ this ->assertEquals ($ expectedPathInfo , $ request ->getPathInfo ());
2098
+ $ this ->assertEquals ($ expectedUri , $ request ->getUri ());
2099
+ $ this ->assertEquals ($ queryString , $ request ->getQueryString ());
2100
+ $ this ->assertEquals (8080 , $ request ->getPort ());
2101
+ $ this ->assertEquals ('host:8080 ' , $ request ->getHttpHost ());
2102
+ $ this ->assertEquals ($ expectedBaseUrl , $ request ->getBaseUrl ());
2103
+ $ this ->assertEquals ($ expectedBasePath , $ request ->getBasePath ());
2104
+ }
2044
2105
}
2045
2106
2046
2107
class RequestContentProxy extends Request
0 commit comments