xref: /PHP-7.2/ext/standard/tests/file/bug72035.phpt (revision 17ccbeec)
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');
6if(php_sapi_name() != "cli") die('skip CLI only test');
7
8$cgi = realpath(dirname(PHP_BINARY)) . DIRECTORY_SEPARATOR . "php-cgi.exe";
9if (!file_exists($cgi)) die('skip CGI binary not found');
10?>
11--FILE--
12<?php
13
14$fl = dirname(__FILE__) . DIRECTORY_SEPARATOR . md5(uniqid()) . ".php";
15$fl = substr($fl, 2);
16
17$cgi = realpath(dirname(PHP_BINARY) . DIRECTORY_SEPARATOR . "php-cgi.exe");
18
19file_put_contents($fl, "<?php echo \"hello\", \"\n\"; ?>");
20
21$cmd = "$cgi -n -C $fl";
22
23/* Need to run CGI with the env reset. */
24$desc = array(0 => array("pipe", "r"));
25$proc = proc_open($cmd, $desc, $pipes, getcwd(), array());
26if (is_resource($proc)) {
27	echo stream_get_contents($pipes[0]);
28
29	proc_close($proc);
30}
31
32unlink($fl);
33?>
34==DONE==
35--EXPECTF--
36X-Powered-By: PHP/%s
37Content-type: text/html; charset=UTF-8
38
39hello
40==DONE==
41