023.phpt 1006 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. --TEST--
  2. HOST/PATH ini sections test for cli
  3. --SKIPIF--
  4. <?php
  5. if (!getenv("TEST_PHP_EXECUTABLE")) die("skip TEST_PHP_EXECUTABLE not set");
  6. if (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";
  13. file_put_contents($ini_file, <<<INI
  14. ; no sections should match as cli doesn't support any
  15. memory_limit = 40M
  16. [PATH={$cwd}]
  17. memory_limit = 50M
  18. [PATH=/does/not/exist]
  19. memory_limit = 60M
  20. [HOST=some_fake_host]
  21. memory_limit = 70M
  22. INI
  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);
  31. if (!$proc) {
  32. exit(1);
  33. }
  34. var_dump(stream_get_contents($pipes[1]));
  35. var_dump(stream_get_contents($pipes[2]));
  36. proc_terminate($proc);
  37. proc_close($proc);
  38. ?>
  39. --CLEAN--
  40. <?php
  41. unlink(__DIR__ . "/023.ini");
  42. ?>
  43. --EXPECT--
  44. string(3) "40M"
  45. string(0) ""