| 67 | } |
| 68 | |
| 69 | func TestCannotCallHandleRequestInNonWorkerMode(t *testing.T) { |
| 70 | runTest(t, func(handler func(http.ResponseWriter, *http.Request), _ *httptest.Server, i int) { |
| 71 | req := httptest.NewRequest("GET", "http://example.com/non-worker.php", nil) |
| 72 | w := httptest.NewRecorder() |
| 73 | handler(w, req) |
| 74 | |
| 75 | resp := w.Result() |
| 76 | body, _ := io.ReadAll(resp.Body) |
| 77 | |
| 78 | assert.Contains(t, string(body), "<b>Fatal error</b>: Uncaught RuntimeException: frankenphp_handle_request() called while not in worker mode") |
| 79 | }, nil) |
| 80 | } |
| 81 | |
| 82 | func TestWorkerEnv(t *testing.T) { |
| 83 | runTest(t, func(handler func(http.ResponseWriter, *http.Request), _ *httptest.Server, i int) { |