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

Function TestGlobalAndModuleWorker

caddy/caddy_test.go:170–221  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

168}
169
170func TestGlobalAndModuleWorker(t *testing.T) {
171 var wg sync.WaitGroup
172 testPortNum, _ := strconv.Atoi(testPort)
173 testPortTwo := strconv.Itoa(testPortNum + 1)
174 tester := caddytest.NewTester(t)
175 initServer(t, tester, `
176 {
177 skip_install_trust
178 admin localhost:2999
179
180 frankenphp {
181 worker {
182 file ../testdata/worker-with-env.php
183 num 1
184 env APP_ENV global
185 }
186 }
187 }
188
189 http://localhost:`+testPort+` {
190 route {
191 php {
192 root ../testdata
193 worker {
194 file worker-with-env.php
195 num 2
196 env APP_ENV module
197 }
198 }
199 }
200 }
201
202 http://localhost:`+testPortTwo+` {
203 route {
204 php {
205 root ../testdata
206 }
207 }
208 }
209 `, "caddyfile")
210
211 for i := range 10 {
212 wg.Add(1)
213
214 go func(i int) {
215 tester.AssertGetResponse("http://localhost:"+testPort+"/worker-with-env.php", http.StatusOK, "Worker has APP_ENV=module")
216 tester.AssertGetResponse("http://localhost:"+testPortTwo+"/worker-with-env.php", http.StatusOK, "Worker has APP_ENV=global")
217 wg.Done()
218 }(i)
219 }
220 wg.Wait()
221}
222
223func TestModuleWorkerInheritsEnv(t *testing.T) {
224 tester := caddytest.NewTester(t)

Callers

nothing calls this directly

Calls 1

initServerFunction · 0.85

Tested by

no test coverage detected