(t *testing.T, opts *testOptions)
| 230 | testPathInfo(t, &testOptions{workerScript: "server-variable.php"}) |
| 231 | } |
| 232 | func testPathInfo(t *testing.T, opts *testOptions) { |
| 233 | cwd, _ := os.Getwd() |
| 234 | testDataDir := cwd + strings.Clone("/testdata/") |
| 235 | path := strings.Clone("/server-variable.php/pathinfo") |
| 236 | |
| 237 | runTest(t, func(_ func(http.ResponseWriter, *http.Request), _ *httptest.Server, i int) { |
| 238 | handler := func(w http.ResponseWriter, r *http.Request) { |
| 239 | requestURI := r.URL.RequestURI() |
| 240 | r.URL.Path = path |
| 241 | |
| 242 | rewriteRequest, err := frankenphp.NewRequestWithContext(r, |
| 243 | frankenphp.WithRequestDocumentRoot(testDataDir, false), |
| 244 | frankenphp.WithRequestEnv(map[string]string{"REQUEST_URI": requestURI}), |
| 245 | ) |
| 246 | assert.NoError(t, err) |
| 247 | |
| 248 | err = frankenphp.ServeHTTP(w, rewriteRequest) |
| 249 | assert.NoError(t, err) |
| 250 | } |
| 251 | |
| 252 | body, _ := testGet(fmt.Sprintf("http://example.com/pathinfo/%d", i), handler, t) |
| 253 | |
| 254 | assert.Contains(t, body, "[PATH_INFO] => /pathinfo") |
| 255 | assert.Contains(t, body, fmt.Sprintf("[REQUEST_URI] => /pathinfo/%d", i)) |
| 256 | assert.Contains(t, body, "[PATH_TRANSLATED] =>") |
| 257 | assert.Contains(t, body, "[SCRIPT_NAME] => /server-variable.php") |
| 258 | |
| 259 | }, opts) |
| 260 | } |
| 261 | |
| 262 | func TestHeaders_module(t *testing.T) { testHeaders(t, nil) } |
| 263 | func TestHeaders_worker(t *testing.T) { testHeaders(t, &testOptions{workerScript: "headers.php"}) } |
no test coverage detected