(t *testing.T)
| 117 | } |
| 118 | |
| 119 | func 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 | |
| 153 | func TestModuleWorkerWithWatchConfiguration(t *testing.T) { |
| 154 | // Create a test configuration with watch directories |
nothing calls this directly
no test coverage detected