@@ -33,6 +33,7 @@ type PHPFPMSuite struct{}
33
33
var _ = Suite (& PHPFPMSuite {})
34
34
35
35
func (s * PHPFPMSuite ) TestGenerateEnv (c * C ) {
36
+
36
37
testdataDir := "testdata"
37
38
tests := []struct {
38
39
uri string
@@ -182,6 +183,94 @@ func (s *PHPFPMSuite) TestGenerateEnv(c *C) {
182
183
"SCRIPT_NAME" : "/index.php" ,
183
184
},
184
185
},
186
+ {
187
+ passthru : "/index.php" ,
188
+ uri : "/subdirectory" ,
189
+ expected : map [string ]string {
190
+ "PATH_INFO" : "" ,
191
+ "REQUEST_URI" : "/subdirectory" ,
192
+ "QUERY_STRING" : "" ,
193
+ "SCRIPT_FILENAME" : testdataDir + "/public/subdirectory/index.php" ,
194
+ "SCRIPT_NAME" : "/subdirectory/index.php" ,
195
+ },
196
+ },
197
+ {
198
+ passthru : "/index.php" ,
199
+ uri : "/subdirectory/" ,
200
+ expected : map [string ]string {
201
+ "PATH_INFO" : "/" ,
202
+ "REQUEST_URI" : "/subdirectory/" ,
203
+ "QUERY_STRING" : "" ,
204
+ "SCRIPT_FILENAME" : testdataDir + "/public/subdirectory/index.php" ,
205
+ "SCRIPT_NAME" : "/subdirectory/index.php" ,
206
+ },
207
+ },
208
+ {
209
+ passthru : "/index.php" ,
210
+ uri : "/subdirectory/unknown.php" ,
211
+ expected : map [string ]string {
212
+ "PATH_INFO" : "/unknown.php" ,
213
+ "REQUEST_URI" : "/subdirectory/unknown.php" ,
214
+ "QUERY_STRING" : "" ,
215
+ "SCRIPT_FILENAME" : testdataDir + "/public/subdirectory/index.php" ,
216
+ "SCRIPT_NAME" : "/subdirectory/index.php" ,
217
+ },
218
+ },
219
+ {
220
+ passthru : "/index.php" ,
221
+ uri : "/subdirectory/unknown.php/" ,
222
+ expected : map [string ]string {
223
+ "PATH_INFO" : "/unknown.php/" ,
224
+ "REQUEST_URI" : "/subdirectory/unknown.php/" ,
225
+ "QUERY_STRING" : "" ,
226
+ "SCRIPT_FILENAME" : testdataDir + "/public/subdirectory/index.php" ,
227
+ "SCRIPT_NAME" : "/subdirectory/index.php" ,
228
+ },
229
+ },
230
+ {
231
+ passthru : "/index.php" ,
<
9E81
/code>
232
+ uri : "/subdirectory/index.php/foo" ,
233
+ expected : map [string ]string {
234
+ "PATH_INFO" : "/foo" ,
235
+ "REQUEST_URI" : "/subdirectory/index.php/foo" ,
236
+ "QUERY_STRING" : "" ,
237
+ "SCRIPT_FILENAME" : testdataDir + "/public/subdirectory/index.php" ,
238
+ "SCRIPT_NAME" : "/subdirectory/index.php" ,
239
+ },
240
+ },
241
+ {
242
+ passthru : "/index.php" ,
243
+ uri : "/subdirectory/subdirectory/" ,
244
+ expected : map [string ]string {
245
+ "PATH_INFO" : "/" ,
246
+ "REQUEST_URI" : "/subdirectory/subdirectory/" ,
247
+ "QUERY_STRING" : "" ,
248
+ "SCRIPT_FILENAME" : testdataDir + "/public/subdirectory/subdirectory/index.php" ,
249
+ "SCRIPT_NAME" : "/subdirectory/subdirectory/index.php" ,
250
+ },
251
+ },
252
+ {
253
+ passthru : "/index.php" ,
254
+ uri : "///subdirectory" ,
255
+ expected : map [string ]string {
256
+ "PATH_INFO" : "" ,
257
+ "REQUEST_URI" : "///subdirectory" ,
258
+ "QUERY_STRING" : "" ,
259
+ "SCRIPT_FILENAME" : testdataDir + "/public/subdirectory/index.php" ,
260
+ "SCRIPT_NAME" : "/subdirectory/index.php" ,
261
+ },
262
+ },
263
+ {
264
+ passthru : "/index.php" ,
265
+ uri : "/subdirectory///subdirectory//foo/" ,
266
+ expected : map [string ]string {
267
+ "PATH_INFO" : "//foo/" ,
268
+ "REQUEST_URI" : "/subdirectory///subdirectory//foo/" ,
269
+ "QUERY_STRING" : "" ,
270
+ "SCRIPT_FILENAME" : testdataDir + "/public/subdirectory/subdirectory/index.php" ,
271
+ "SCRIPT_NAME" : "/subdirectory/subdirectory/index.php" ,
272
+ },
273
+ },
185
274
}
186
275
for _ , test := range tests {
187
276
process := & Server {
@@ -197,7 +286,7 @@ func (s *PHPFPMSuite) TestGenerateEnv(c *C) {
197
286
for k , v := range test .expected {
198
287
vv , ok := env [k ]
199
288
c .Assert (ok , Equals , true )
200
- c .Assert (vv , DeepEquals , v )
289
+ c .Assert (vv , DeepEquals , v , Commentf ( "#test uri: \" %s \" varName: \" %s \" " , test . uri , k ) )
201
290
}
202
291
}
203
292
}
0 commit comments