diff --git a/sapi/cgi/tests/003.phpt b/sapi/cgi/tests/003.phpt index 533743323f..1ba94f27ef 100644 --- a/sapi/cgi/tests/003.phpt +++ b/sapi/cgi/tests/003.phpt @@ -2,6 +2,11 @@ strip comments and whitespace with -w --SKIPIF-- --FILE-- diff --git a/sapi/cgi/tests/004.phpt b/sapi/cgi/tests/004.phpt index 8769126561..0e7117080d 100644 --- a/sapi/cgi/tests/004.phpt +++ b/sapi/cgi/tests/004.phpt @@ -26,7 +26,11 @@ var_dump(test::$pri); file_put_contents($filename, $code); -var_dump(`$php -n -f "$filename" 2>/dev/null`); +if (defined("PHP_WINDOWS_VERSION_MAJOR")) { + var_dump(`$php -n -f "$filename"`); +} else { + var_dump(`$php -n -f "$filename" 2>/dev/null`); +} var_dump(`$php -n -f "wrong"`); @unlink($filename); diff --git a/sapi/cgi/tests/005-win32.phpt b/sapi/cgi/tests/005-win32.phpt new file mode 100644 index 0000000000..b7efb9b500 --- /dev/null +++ b/sapi/cgi/tests/005-win32.phpt @@ -0,0 +1,34 @@ +--TEST-- +using invalid combinations of cmdline options +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +string(51) "Interactive mode enabled + +No input file specified. +" +string(51) "Interactive mode enabled + +No input file specified. +" +Done diff --git a/sapi/cgi/tests/005.phpt b/sapi/cgi/tests/005.phpt index 34a28f9c5e..259005f3d9 100644 --- a/sapi/cgi/tests/005.phpt +++ b/sapi/cgi/tests/005.phpt @@ -1,7 +1,14 @@ --TEST-- using invalid combinations of cmdline options --SKIPIF-- - + --FILE-- /dev/null`); +if (defined("PHP_WINDOWS_VERSION_MAJOR")) { + var_dump(`"$php" -n -l "$filename"`); +} else { + var_dump(`"$php" -n -l "$filename" 2>/dev/null`); +} @unlink($filename); diff --git a/sapi/cgi/tests/include.inc b/sapi/cgi/tests/include.inc index 2d8ed8a2e3..dc98dc0f23 100644 --- a/sapi/cgi/tests/include.inc +++ b/sapi/cgi/tests/include.inc @@ -21,18 +21,27 @@ function get_cgi_path() /* {{{ */ if ($cli) { /* trying to guess ... */ $php_path = $php; - for ($i = 0; $i < 2; $i++) { - $slash_pos = strrpos($php_path, "/"); - if ($slash_pos) { - $php_path = substr($php_path, 0, $slash_pos); - } else { - return FALSE; - } - } + if (defined("PHP_WINDOWS_VERSION_MAJOR")) { + /* On Windows it should be in the same dir as php.exe in most of the cases. */ + $php_path = dirname($php); - if ($php_path && is_dir($php_path) && file_exists($php_path."/cgi/php-cgi") && is_executable($php_path."/cgi/php-cgi")) { - /* gotcha */ - return $php_path."/cgi/php-cgi"; + if (is_dir($php_path) && file_exists("$php_path/php-cgi.exe") && is_executable("$php_path/php-cgi.exe")) { + return "$php_path/php-cgi.exe"; + } + } else { + for ($i = 0; $i < 2; $i++) { + $slash_pos = strrpos($php_path, "/"); + if ($slash_pos) { + $php_path = substr($php_path, 0, $slash_pos); + } else { + return FALSE; + } + } + + if ($php_path && is_dir($php_path) && file_exists($php_path."/cgi/php-cgi") && is_executable($php_path."/cgi/php-cgi")) { + /* gotcha */ + return $php_path."/cgi/php-cgi"; + } } return false; } diff --git a/sapi/cgi/tests/skipif.inc b/sapi/cgi/tests/skipif.inc index 9da8b7934d..d2cef23589 100644 --- a/sapi/cgi/tests/skipif.inc +++ b/sapi/cgi/tests/skipif.inc @@ -4,10 +4,6 @@ if (substr(php_sapi_name(), 0, 3) == "cgi") { exit; } -if (substr(PHP_OS, 0, 3) == 'WIN') { - die ("skip not for Windows"); -} - include dirname(__FILE__)."/include.inc"; if (!get_cgi_path()) {