1--TEST--
2FPM: GH-13563 - conf boolean environment variables values
3--SKIPIF--
4<?php
5include "skipif.inc";
6FPM\Tester::skipIfRoot();
7?>
8--FILE--
9<?php
10
11require_once "tester.inc";
12
13$cfg = <<<EOT
14[global]
15error_log = {{FILE:LOG}}
16log_limit = 1024
17log_buffering = \${FPM_TEST_LOG_BUF}
18daemonize = \${FPM_TEST_DAEMONIZE}
19[unconfined]
20listen = {{ADDR}}
21process.dumpable = \${FPM_TEST_PROC_DUMP}
22pm = dynamic
23pm.max_children = 5
24pm.start_servers = 1
25pm.min_spare_servers = 1
26pm.max_spare_servers = 3
27request_terminate_timeout_track_finished = \${FPM_TEST_REQ_TERM_TRACK_FIN}
28catch_workers_output = \${FPM_TEST_CATCH_WRK_OUT}
29decorate_workers_output = \${FPM_TEST_DECOR_WRK_OUT}
30clear_env = \${FPM_TEST_CLEAR_ENV}
31EOT;
32
33$code = <<<EOT
34<?php
35foreach (getenv() as \$name => \$val) {
36    if (str_starts_with(\$name, 'FPM_TEST')) {
37        printf("%s: %s\n", \$name, \$val);
38    }
39}
40file_put_contents('php://stderr', str_repeat('a', 20) . "\n");
41EOT;
42
43$tester = new FPM\Tester($cfg, $code);
44$tester->start(envVars: [
45    'FPM_TEST_LOG_BUF' => 'on',
46    'FPM_TEST_DAEMONIZE' => 'false',
47    'FPM_TEST_PROC_DUMP' => 'no',
48    'FPM_TEST_CATCH_WRK_OUT' => 'yes',
49    'FPM_TEST_DECOR_WRK_OUT' => 'true',
50    'FPM_TEST_CLEAR_ENV' => 'none',
51    'FPM_TEST_REQ_TERM_TRACK_FIN' => '0',
52]);
53$tester->expectLogStartNotices();
54$tester->request()->expectBody([
55    'FPM_TEST_LOG_BUF: on',
56    'FPM_TEST_DAEMONIZE: false',
57    'FPM_TEST_PROC_DUMP: no',
58    'FPM_TEST_CATCH_WRK_OUT: yes',
59    'FPM_TEST_DECOR_WRK_OUT: true',
60    'FPM_TEST_CLEAR_ENV: none',
61    'FPM_TEST_REQ_TERM_TRACK_FIN: 0',
62]);
63$tester->terminate();
64$tester->expectLogMessage('a', 1024, 20, true);
65$tester->close();
66
67?>
68Done
69--EXPECT--
70Done
71--CLEAN--
72<?php
73require_once "tester.inc";
74FPM\Tester::clean();
75?>
76