@@ -1286,6 +1286,12 @@ public function testGetPathInfo()
1286
1286
$ request ->initialize (array (), array (), array (), array (), array (), $ server );
1287
1287
1288
1288
$ this ->assertEquals ('/path%20test/info ' , $ request ->getPathInfo ());
1289
+
1290
+ $ server = array ();
1291
+ $ server ['REQUEST_URI ' ] = '?a=b ' ;
1292
+ $ request ->initialize (array (), array (), array (), array (), array (), $ server );
1293
+
1294
+ $ this ->assertEquals ('/ ' , $ request ->getPathInfo ());
1289
1295
}
1290
1296
1291
1297
public function testGetParameterPrecedence ()
@@ -2188,6 +2194,61 @@ public function testGetTrustedHeaderName()
2188
2194
Request::setTrustedHeaderName (Request::HEADER_CLIENT_PORT , 'X_FORWARDED_PORT ' );
2189
2195
Request::setTrustedHeaderName (Request::HEADER_CLIENT_PROTO , 'X_FORWARDED_PROTO ' );
2190
2196
}
2197
+
2198
+ public function nonstandardRequestsData ()
2199
+ {
2200
+ return array (
2201
+ array ('' , '' , '/ ' , 'http://host:8080/ ' , '' ),
2202
+ array ('/ ' , '' , '/ ' , 'http://host:8080/ ' , '' ),
2203
+
2204
+ array ('hello/app.php/x ' , '' , '/x ' , 'http://host:8080/hello/app.php/x ' , '/hello ' , '/hello/app.php ' ),
2205
+ array ('/hello/app.php/x ' , '' , '/x ' , 'http://host:8080/hello/app.php/x ' , '/hello ' , '/hello/app.php ' ),
2206
+
2207
+ array ('' , 'a=b ' , '/ ' , 'http://host:8080/?a=b ' ),
2208
+ array ('?a=b ' , 'a=b ' , '/ ' , 'http://host:8080/?a=b ' ),
2209
+ array ('/?a=b ' , 'a=b ' , '/ ' , 'http://host:8080/?a=b ' ),
2210
+
2211
+ array ('x ' , 'a=b ' , '/x ' , 'http://host:8080/x?a=b ' ),
2212
+ array ('x?a=b ' , 'a=b ' , '/x ' , 'http://host:8080/x?a=b ' ),
2213
+ array ('/x?a=b ' , 'a=b ' , '/x ' , 'http://host:8080/x?a=b ' ),
2214
+
2215
+ array ('hello/x ' , '' , '/x ' , 'http://host:8080/hello/x ' , '/hello ' ),
2216
+ array ('/hello/x ' , '' , '/x ' , 'http://host:8080/hello/x ' , '/hello ' ),
2217
+
2218
+ array ('hello/app.php/x ' , 'a=b ' , '/x ' , 'http://host:8080/hello/app.php/x?a=b ' , '/hello ' , '/hello/app.php ' ),
2219
+ array ('hello/app.php/x?a=b ' , 'a=b ' , '/x ' , 'http://host:8080/hello/app.php/x?a=b ' , '/hello ' , '/hello/app.php ' ),
2220
+ array ('/hello/app.php/x?a=b ' , 'a=b ' , '/x ' , 'http://host:8080/hello/app.php/x?a=b ' , '/hello ' , '/hello/app.php ' ),
2221
+ );
2222
+ }
2223
+
2224
+ /**
2225
+ * @dataProvider nonstandardRequestsData
2226
+ */
2227
+ public function testNonstandardRequests ($ requestUri , $ queryString , $ expectedPathInfo , $ expectedUri , $ expectedBasePath = '' , $ expectedBaseUrl = null )
2228
+ {
2229
+ if (null === $ expectedBaseUrl ) {
2230
+ $ expectedBaseUrl = $ expectedBasePath ;
2231
+ }
2232
+
2233
+ $ server = array (
2234
+ 'HTTP_HOST ' => 'host:8080 ' ,
2235
+ 'SERVER_PORT ' => '8080 ' ,
2236
+ 'QUERY_STRING ' => $ queryString ,
2237
+ 'PHP_SELF ' => '/hello/app.php ' ,
2238
+ 'SCRIPT_FILENAME ' => '/some/path/app.php ' ,
2239
+ 'REQUEST_URI ' => $ requestUri ,
2240
+ );
2241
+
2242
+ $ request = new Request (array (), array (), array (), array (), array (), $ server );
2243
+
2244
+ $ this ->assertEquals ($ expectedPathInfo , $ request ->getPathInfo ());
2245
+ $ this ->assertEquals ($ expectedUri , $ request ->getUri ());
2246
+ $ this ->assertEquals ($ queryString , $ request ->getQueryString ());
2247
+ $ this ->assertEquals (8080 , $ request ->getPort ());
2248
+ $ this ->assertEquals ('host:8080 ' , $ request ->getHttpHost ());
2249
+ $ this ->assertEquals ($ expectedBaseUrl , $ request ->getBaseUrl ());
2250
+ $ this ->assertEquals ($ expectedBasePath , $ request ->getBasePath ());
2251
+ }
2191
2252
}
2192
2253
2193
2254
class RequestContentProxy extends Request
0 commit comments