@@ -1281,6 +1281,12 @@ public function testGetPathInfo()
1281
1281
$ request ->initialize (array (), array (), array (), array (), array (), $ server );
1282
1282
1283
1283
$ this ->assertEquals ('/path%20test/info ' , $ request ->getPathInfo ());
1284
+
1285
+ $ server = array ();
1286
+ $ server ['REQUEST_URI ' ] = '?a=b ' ;
1287
+ $ request ->initialize (array (), array (), array (), array (), array (), $ server );
1288
+
1289
+ $ this ->assertEquals ('/ ' , $ request ->getPathInfo ());
1284
1290
}
1285
1291
1286
1292
public function testGetParameterPrecedence ()
@@ -2110,6 +2116,61 @@ public function methodCacheableProvider()
2110
2116
array ('CONNECT ' , false ),
2111
2117
);
2112
2118
}
2119
+
2120
+ public function nonstandardRequestsData ()
2121
+ {
2122
+ return array (
2123
+ array ('' , '' , '/ ' , 'http://host:8080/ ' , '' ),
2124
+ array ('/ ' , '' , '/ ' , 'http://host:8080/ ' , '' ),
2125
+
2126
+ array ('hello/app.php/x ' , '' , '/x ' , 'http://host:8080/hello/app.php/x ' , '/hello ' , '/hello/app.php ' ),
2127
+ array ('/hello/app.php/x ' , '' , '/x ' , 'http://host:8080/hello/app.php/x ' , '/hello ' , '/hello/app.php ' ),
2128
+
2129
+ array ('' , 'a=b ' , '/ ' , 'http://host:8080/?a=b ' ),
2130
+ array ('?a=b ' , 'a=b ' , '/ ' , 'http://host:8080/?a=b ' ),
2131
+ array ('/?a=b ' , 'a=b ' , '/ ' , 'http://host:8080/?a=b ' ),
2132
+
2133
+ array ('x ' , 'a=b ' , '/x ' , 'http://host:8080/x?a=b ' ),
2134
+ array ('x?a=b ' , 'a=b ' , '/x ' , 'http://host:8080/x?a=b ' ),
2135
+ array ('/x?a=b ' , 'a=b ' , '/x ' , 'http://host:8080/x?a=b ' ),
2136
+
2137
+ array ('hello/x ' , '' , '/x ' , 'http://host:8080/hello/x ' , '/hello ' ),
2138
+ array ('/hello/x ' , '' , '/x ' , 'http://host:8080/hello/x ' , '/hello ' ),
2139
+
2140
+ array ('hello/app.php/x ' , 'a=b ' , '/x ' , 'http://host:8080/hello/app.php/x?a=b ' , '/hello ' , '/hello/app.php ' ),
2141
+ array ('hello/app.php/x?a=b ' , 'a=b ' , '/x ' , 'http://host:8080/hello/app.php/x?a=b ' , '/hello ' , '/hello/app.php ' ),
2142
+ array ('/hello/app.php/x?a=b ' , 'a=b ' , '/x ' , 'http://host:8080/hello/app.php/x?a=b ' , '/hello ' , '/hello/app.php ' ),
2143
+ );
2144
+ }
2145
+
2146
+ /**
2147
+ * @dataProvider nonstandardRequestsData
2148
+ */
2149
+ public function testNonstandardRequests ($ requestUri , $ queryString , $ expectedPathInfo , $ expectedUri , $ expectedBasePath = '' , $ expectedBaseUrl = null )
2150
+ {
2151
+ if (null === $ expectedBaseUrl ) {
2152
+ $ expectedBaseUrl = $ expectedBasePath ;
2153
+ }
2154
+
2155
+ $ server = array (
2156
+ 'HTTP_HOST ' => 'host:8080 ' ,
2157
+ 'SERVER_PORT ' => '8080 ' ,
2158
+ 'QUERY_STRING ' => $ queryString ,
2159
+ 'PHP_SELF ' => '/hello/app.php ' ,
2160
+ 'SCRIPT_FILENAME ' => '/some/path/app.php ' ,
2161
+ 'REQUEST_URI ' => $ requestUri ,
2162
+ );
2163
+
2164
+ $ request = new Request (array (), array (), array (), array (), array (), $ server );
2165
+
2166
+ $ this ->assertEquals ($ expectedPathInfo , $ request ->getPathInfo ());
2167
+ $ this ->assertEquals ($ expectedUri , $ request ->getUri ());
2168
+ $ this ->assertEquals ($ queryString , $ request ->getQueryString ());
2169
+ $ this ->assertEquals (8080 , $ request ->getPort ());
2170
+ $ this ->assertEquals ('host:8080 ' , $ request ->getHttpHost ());
2171
+ $ this ->assertEquals ($ expectedBaseUrl , $ request ->getBaseUrl ());
2172
+ $ this ->assertEquals ($ expectedBasePath , $ request ->getBasePath ());
2173
+ }
2113
2174
}
2114
2175
2115
2176
class RequestContentProxy extends Request
0 commit comments