xref: /PHP-8.1/ext/standard/tests/file/bug72035.phpt (revision f8d79582)
1--TEST--
2Bug #72035 php-cgi.exe fails to run scripts relative to drive root
3--SKIPIF--
4<?php
5if(substr(PHP_OS, 0, 3) != 'WIN' ) die('skip windows only test');
6
7$cgi = realpath(dirname(PHP_BINARY)) . DIRECTORY_SEPARATOR . "php-cgi.exe";
8if (!file_exists($cgi)) die('skip CGI binary not found');
9?>
10--FILE--
11<?php
12
13$fl = __DIR__ . DIRECTORY_SEPARATOR . md5(uniqid()) . ".php";
14$fl = substr($fl, 2);
15
16$cgi = realpath(dirname(PHP_BINARY) . DIRECTORY_SEPARATOR . "php-cgi.exe");
17
18file_put_contents($fl, "<?php echo \"hello\", \"\n\"; ?>");
19
20$cmd = "$cgi -n -C $fl";
21
22/* Need to run CGI with the env reset. */
23$desc = array(0 => array("pipe", "r"));
24$proc = proc_open($cmd, $desc, $pipes, getcwd(), array());
25if (is_resource($proc)) {
26    echo stream_get_contents($pipes[0]);
27
28    proc_close($proc);
29}
30
31unlink($fl);
32?>
33--EXPECTF--
34X-Powered-By: PHP/%s
35Content-type: text/html; charset=UTF-8
36
37hello
38