MCPcopy Index your code
hub / github.com/php/frankenphp / testPathInfo

Function testPathInfo

frankenphp_test.go:232–260  ·  view source on GitHub ↗
(t *testing.T, opts *testOptions)

Source from the content-addressed store, hash-verified

230 testPathInfo(t, &testOptions{workerScript: "server-variable.php"})
231}
232func 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
262func TestHeaders_module(t *testing.T) { testHeaders(t, nil) }
263func TestHeaders_worker(t *testing.T) { testHeaders(t, &testOptions{workerScript: "headers.php"}) }

Callers 2

TestPathInfo_moduleFunction · 0.85
TestPathInfo_workerFunction · 0.85

Calls 6

NewRequestWithContextFunction · 0.92
WithRequestDocumentRootFunction · 0.92
WithRequestEnvFunction · 0.92
ServeHTTPFunction · 0.92
runTestFunction · 0.85
testGetFunction · 0.85

Tested by

no test coverage detected