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

Function TestModuleWorkerWithEnvironmentVariables

caddy/config_test.go:119–151  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

117}
118
119func TestModuleWorkerWithEnvironmentVariables(t *testing.T) {
120 // Create a test configuration with environment variables
121 configWithEnv := `
122 {
123 php {
124 worker {
125 file ../testdata/worker-with-env.php
126 num 1
127 env APP_ENV production
128 env DEBUG true
129 }
130 }
131 }`
132
133 // Parse the configuration
134 d := caddyfile.NewTestDispenser(configWithEnv)
135 module := &FrankenPHPModule{}
136
137 // Unmarshal the configuration
138 err := module.UnmarshalCaddyfile(d)
139
140 // Verify that no error was returned
141 require.NoError(t, err, "Expected no error when configuring a worker with environment variables")
142
143 // Verify that the worker was added to the module
144 require.Len(t, module.Workers, 1, "Expected one worker to be added to the module")
145 require.Equal(t, "../testdata/worker-with-env.php", module.Workers[0].FileName, "Worker should have the correct filename")
146
147 // Verify that the environment variables were set correctly
148 require.Len(t, module.Workers[0].Env, 2, "Expected two environment variables")
149 require.Equal(t, "production", module.Workers[0].Env["APP_ENV"], "APP_ENV should be set to production")
150 require.Equal(t, "true", module.Workers[0].Env["DEBUG"], "DEBUG should be set to true")
151}
152
153func TestModuleWorkerWithWatchConfiguration(t *testing.T) {
154 // Create a test configuration with watch directories

Callers

nothing calls this directly

Calls 1

UnmarshalCaddyfileMethod · 0.95

Tested by

no test coverage detected