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

Function TestWorkerGetOpt

worker_test.go:95–113  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

93}
94
95func TestWorkerGetOpt(t *testing.T) {
96 logger, buf := newTestLogger(t)
97
98 runTest(t, func(handler func(http.ResponseWriter, *http.Request), _ *httptest.Server, i int) {
99 req := httptest.NewRequest("GET", fmt.Sprintf("http://example.com/worker-getopt.php?i=%d", i), nil)
100 req.Header.Add("Request", strconv.Itoa(i))
101 w := httptest.NewRecorder()
102
103 handler(w, req)
104
105 resp := w.Result()
106 body, _ := io.ReadAll(resp.Body)
107
108 assert.Contains(t, string(body), fmt.Sprintf("[HTTP_REQUEST] => %d", i))
109 assert.Contains(t, string(body), fmt.Sprintf("[REQUEST_URI] => /worker-getopt.php?i=%d", i))
110 }, &testOptions{logger: logger, workerScript: "worker-getopt.php", env: map[string]string{"FOO": "bar"}})
111
112 assert.NotRegexp(t, buf.String(), "exit_status=[1-9]")
113}
114
115func ExampleServeHTTP_workers() {
116 if err := frankenphp.Init(

Callers

nothing calls this directly

Calls 4

newTestLoggerFunction · 0.85
runTestFunction · 0.85
ResultMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected