xref: /PHP-8.3/sapi/cli/tests/023.phpt (revision dcc3255b)
1--TEST--
2HOST/PATH ini sections test for cli
3--SKIPIF--
4<?php
5if (!getenv("TEST_PHP_EXECUTABLE")) die("skip TEST_PHP_EXECUTABLE not set");
6if (substr(PHP_OS, 0, 3) == "WIN") die("skip non windows test");
7?>
8--FILE--
9<?php
10$php = getenv("TEST_PHP_EXECUTABLE_ESCAPED");
11$cwd = getcwd();
12$ini_file = __DIR__ . "/023.ini";
13$ini_file_escaped = escapeshellarg($ini_file);
14file_put_contents($ini_file, <<<INI
15; no sections should match as cli doesn't support any
16memory_limit = 40M
17[PATH={$cwd}]
18memory_limit = 50M
19[PATH=/does/not/exist]
20memory_limit = 60M
21[HOST=some_fake_host]
22memory_limit = 70M
23INI
24);
25$desc = array(
26    0 => array("pipe", "r"),
27    1 => array("pipe", "w"),
28    2 => array("pipe", "w"),
29);
30$pipes = array();
31$proc = proc_open("$php -c $ini_file_escaped -r 'echo ini_get(\"memory_limit\");'", $desc, $pipes);
32if (!$proc) {
33    exit(1);
34}
35var_dump(stream_get_contents($pipes[1]));
36var_dump(stream_get_contents($pipes[2]));
37
38proc_terminate($proc);
39proc_close($proc);
40?>
41--CLEAN--
42<?php
43unlink(__DIR__ . "/023.ini");
44?>
45--EXPECT--
46string(3) "40M"
47string(0) ""
48