xref: /PHP-8.0/sapi/cli/tests/023.phpt (revision f8d79582)
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");
11$cwd = getcwd();
12$ini_file = __DIR__ . "/023.ini";
13file_put_contents($ini_file, <<<INI
14; no sections should match as cli doesn't support any
15memory_limit = 40M
16[PATH={$cwd}]
17memory_limit = 50M
18[PATH=/does/not/exist]
19memory_limit = 60M
20[HOST=some_fake_host]
21memory_limit = 70M
22INI
23);
24$desc = array(
25    0 => array("pipe", "r"),
26    1 => array("pipe", "w"),
27    2 => array("pipe", "w"),
28);
29$pipes = array();
30$proc = proc_open("$php -c $ini_file -r 'echo ini_get(\"memory_limit\");'", $desc, $pipes);
31if (!$proc) {
32    exit(1);
33}
34var_dump(stream_get_contents($pipes[1]));
35var_dump(stream_get_contents($pipes[2]));
36
37proc_terminate($proc);
38proc_close($proc);
39?>
40--CLEAN--
41<?php
42unlink(__DIR__ . "/023.ini");
43?>
44--EXPECT--
45string(3) "40M"
46string(0) ""
47