tony2001 Tue Apr 17 19:49:26 2007 UTC Added files: (Branch: PHP_5_2) /php-src/sapi/cgi/tests 001.phpt 002.phpt 003.phpt 004.phpt 005.phpt 006.phpt 007.phpt 008.phpt include.inc skipif.inc
Modified files: /php-src run-tests.php Log: add tests for CGI
http://cvs.php.net/viewvc.cgi/php-src/run-tests.php?r1=1.226.2.37.2.24&r2=1.226.2.37.2.25&diff_format=u Index: php-src/run-tests.php diff -u php-src/run-tests.php:1.226.2.37.2.24 php-src/run-tests.php:1.226.2.37.2.25 --- php-src/run-tests.php:1.226.2.37.2.24 Tue Mar 27 20:28:06 2007 +++ php-src/run-tests.php Tue Apr 17 19:49:26 2007 @@ -23,7 +23,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: run-tests.php,v 1.226.2.37.2.24 2007/03/27 20:28:06 helly Exp $ */ +/* $Id: run-tests.php,v 1.226.2.37.2.25 2007/04/17 19:49:26 tony2001 Exp $ */ /* Sanity check to ensure that pcre extension needed by this script is available. * In the event it is not, print a nice error message indicating that this script will @@ -398,7 +398,7 @@ $html_output = is_resource($html_file); break; case '--version': - echo '$Revision: 1.226.2.37.2.24 $'."\n"; + echo '$Revision: 1.226.2.37.2.25 $'."\n"; exit(1); default: echo "Illegal switch '$switch' specified!\n"; @@ -534,7 +534,7 @@ $ignored_by_ext = 0; sort($exts_to_test); $test_dirs = array(); -$optionals = array('tests', 'ext', 'Zend', 'ZendEngine2', 'sapi/cli'); +$optionals = array('tests', 'ext', 'Zend', 'ZendEngine2', 'sapi/cli', 'sapi/cgi'); foreach($optionals as $dir) { if (@filetype($dir) == 'dir') { $test_dirs[] = $dir; http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/tests/001.phpt?view=markup&rev=1.1 Index: php-src/sapi/cgi/tests/001.phpt +++ php-src/sapi/cgi/tests/001.phpt --TEST-- version string --SKIPIF-- <?php include "skipif.inc"; ?> --FILE-- <?php include "include.inc"; $php = get_cgi_path(); reset_env_vars(); var_dump(`$php -n -v`); echo "Done\n"; ?> --EXPECTF-- string(%d) "PHP %s (cgi%s (built: %s Copyright (c) 1997-20%s The PHP Group Zend Engine v%s, Copyright (c) 1998-20%s Zend Technologies " Done http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/tests/002.phpt?view=markup&rev=1.1 Index: php-src/sapi/cgi/tests/002.phpt +++ php-src/sapi/cgi/tests/002.phpt --TEST-- defining INI options with -d --SKIPIF-- <?php include "skipif.inc"; ?> --FILE-- <?php include "include.inc"; $php = get_cgi_path(); reset_env_vars(); $file = dirname(__FILE__)."/002.test.php"; file_put_contents($file, '<?php var_dump(ini_get("max_execution_time")); ?>'); var_dump(`$php -n -d max_execution_time=111 $file`); var_dump(`$php -n -d max_execution_time=500 $file`); var_dump(`$php -n -d max_execution_time=500 -d max_execution_time=555 $file`); file_put_contents($file, '<?php var_dump(ini_get("max_execution_time")); var_dump(ini_get("upload_tmp_dir")); ?>'); var_dump(`$php -n -d upload_tmp_dir=/test/path -d max_execution_time=555 $file`); unlink($file); echo "Done\n"; ?> --EXPECTF-- string(%d) "X-Powered-By: PHP/%s Content-type: text/html string(3) "111" " string(%d) "X-Powered-By: PHP/%s Content-type: text/html string(3) "500" " string(%d) "X-Powered-By: PHP/%s Content-type: text/html string(3) "555" " string(%d) "X-Powered-By: PHP/%s Content-type: text/html string(3) "555" string(10) "/test/path" " Done http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/tests/003.phpt?view=markup&rev=1.1 Index: php-src/sapi/cgi/tests/003.phpt +++ php-src/sapi/cgi/tests/003.phpt --TEST-- strip comments and whitespace with -w --SKIPIF-- <?php include "skipif.inc"; ?> --FILE-- <?php include "include.inc"; $php = get_cgi_path(); reset_env_vars(); $filename = dirname(__FILE__).'/003.test.php'; $code =' <?php /* some test script */ class test { /* {{{ */ public $var = "test"; //test var #perl style comment private $pri; /* private attr */ function foo(/* void */) { } } /* }}} */ ?> '; file_put_contents($filename, $code); var_dump(`$php -n -w "$filename"`); var_dump(`$php -n -w "wrong"`); var_dump(`echo "<?php /* comment */ class test {\n // comment \n function foo() {} } ?>" | $php -n -w`); @unlink($filename); echo "Done\n"; ?> --EXPECTF-- string(%d) "X-Powered-By: PHP/%s Content-type: text/html <?php class test { public $var = "test"; private $pri; function foo() { } } ?> " string(%d) "Status: 404 X-Powered-By: PHP/%s Content-type: text/html No input file specified. " string(%d) "X-Powered-By: PHP/%s Content-type: text/html <?php class test { function foo() {} } ?> " Done http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/tests/004.phpt?view=markup&rev=1.1 Index: php-src/sapi/cgi/tests/004.phpt +++ php-src/sapi/cgi/tests/004.phpt --TEST-- execute a file with -f --SKIPIF-- <?php include "skipif.inc"; ?> --FILE-- <?php include "include.inc"; $php = get_cgi_path(); reset_env_vars(); $filename = dirname(__FILE__).'/004.test.php'; $code =' <?php class test { private $pri; } var_dump(test::$pri); ?> '; file_put_contents($filename, $code); var_dump(`$php -n -f "$filename" 2>/dev/null`); var_dump(`$php -n -f "wrong"`); @unlink($filename); echo "Done\n"; ?> --EXPECTF-- string(%d) " <br /> <b>Fatal error</b>: Cannot access private property test::$pri in <b>%s004.test.php</b> on line <b>8</b><br /> " string(25) "No input file specified. " Done http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/tests/005.phpt?view=markup&rev=1.1 Index: php-src/sapi/cgi/tests/005.phpt +++ php-src/sapi/cgi/tests/005.phpt --TEST-- using invalid combinations of cmdline options --SKIPIF-- <?php include "skipif.inc"; ?> --FILE-- <?php include "include.inc"; $php = get_cgi_path(); reset_env_vars(); var_dump(`$php -n -c -f 'wrong'`); var_dump(`$php -n -a -f 'wrong'`); var_dump(`$php -n -f 'wrong' -a`); echo "Done\n"; ?> --EXPECTF-- string(55) "You cannot use both -n and -c switch. Use -h for help. " string(51) "No input file specified. Interactive mode enabled " string(51) "No input file specified. Interactive mode enabled " Done http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/tests/006.phpt?view=markup&rev=1.1 Index: php-src/sapi/cgi/tests/006.phpt +++ php-src/sapi/cgi/tests/006.phpt --TEST-- syntax check --SKIPIF-- <?php include "skipif.inc"; ?> --FILE-- <?php include "include.inc"; $php = get_cgi_path(); reset_env_vars(); $filename = dirname(__FILE__)."/006.test.php"; $code = ' <?php $test = "var"; class test { private $var; } echo test::$var; ?> '; file_put_contents($filename, $code); var_dump(`"$php" -n -l "$filename"`); var_dump(`"$php" -n -l some.unknown`); $code = ' <?php class test private $var; } ?> '; file_put_contents($filename, $code); var_dump(`"$php" -n -l "$filename" 2>/dev/null`); @unlink($filename); echo "Done\n"; ?> --EXPECTF-- string(%d) "No syntax errors detected in %s006.test.php " string(%d) "No input file specified. " string(%d) "<br /> <b>Parse error</b>: syntax error, unexpected T_PRIVATE, expecting '{' in <b>%s006.test.php</b> on line <b>5</b><br /> Errors parsing %s006.test.php " Done http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/tests/007.phpt?view=markup&rev=1.1 Index: php-src/sapi/cgi/tests/007.phpt +++ php-src/sapi/cgi/tests/007.phpt --TEST-- invalid arguments and error messages --SKIPIF-- <?php include "skipif.inc"; ?> --FILE-- <?php include "include.inc"; $php = get_cgi_path(); reset_env_vars(); var_dump(`"$php" -n -f some.php -f some.php`); var_dump(`"$php" -s -w -l`); echo "Done\n"; ?> --EXPECTF-- string(25) "No input file specified. " string(31) "No syntax errors detected in - " Done http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/tests/008.phpt?view=markup&rev=1.1 Index: php-src/sapi/cgi/tests/008.phpt +++ php-src/sapi/cgi/tests/008.phpt --TEST-- syntax highlighting --SKIPIF-- <?php include "skipif.inc"; ?> --FILE-- <?php include "include.inc"; $php = get_cgi_path(); reset_env_vars(); $filename = dirname(__FILE__)."/008.test.php"; $code = ' <?php $test = "var"; //var /* test class */ class test { private $var = array(); public static function foo(Test $arg) { echo "hello"; var_dump($this); } } $o = new test; ?> '; file_put_contents($filename, $code); var_dump(`"$php" -n -s "$filename"`); var_dump(`"$php" -n -s "unknown"`); @unlink($filename); echo "Done\n"; ?> --EXPECTF-- string(%d) "X-Powered-By: PHP/%s Content-type: text/html <code><span style="color: #000000"> <br /><span style="color: #0000BB"><?php<br />$test </span><span style="color: #007700">= </span><span style="color: #DD0000">"var"</span><span style="color: #007700">; </span><span style="color: #FF8000">//var<br />/* test class */<br /></span><span style="color: #007700">class </span><span style="color: #0000BB">test </span><span style="color: #007700">{<br /> private </span><span style="color: #0000BB">$var </span><span style="color: #007700">= array();<br /><br /> public static function </span><span style="color: #0000BB">foo</span><span style="color: #007700">(</span><span style="color: #0000BB">Test $arg</span><span style="color: #007700">) {<br /> echo </span><span style="color: #DD0000">"hello"</span><span style="color: #007700">;<br /> </span! ><span style="color: #0000BB">var_dump</span><span style="color: >#007700">(</span><span style="color: #0000BB">$this</span><span style="color: >#007700">);<br /> }<br />}<br /><br /></span><span >style="color: #0000BB">$o </span><span style="color: >#007700">= new </span><span style="color: #0000BB">test</span><span >style="color: #007700">;<br /></span><span style="color: #0000BB">?><br >/></span> </span> </code>" string(%d) "Status: 404 X-Powered-By: PHP/%s Content-type: text/html No input file specified. " Done http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/tests/include.inc?view=markup&rev=1.1 Index: php-src/sapi/cgi/tests/include.inc +++ php-src/sapi/cgi/tests/include.inc <?php function get_cgi_path() /* {{{ */ { $php = getenv("TEST_PHP_EXECUTABLE"); $cli = false; $cgi = false; if (file_exists($php) && is_executable($php)) { $version = `$php -v`; if (strstr($version, "(cli)")) { /* that's cli */ $cli = true; } else if (strpos($version, "(cgi")) { /* that's cgi */ return $php; } } 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 ($php_path && is_dir($php_path) && file_exists($php_path."/cgi/php") && is_executable($php_path."/cgi/php")) { /* gotcha */ return $php_path."/cgi/php"; } return false; } /* uhm? what's that then? */ return false; } /* }}} */ function reset_env_vars() /* {{{ */ { putenv("REDIRECT_STATUS"); putenv("QUERY_STRING"); putenv("PATH_TRANSLATED"); putenv("SCRIPT_FILENAME"); putenv("SERVER_SOFTWARE"); putenv("SERVER_NAME"); putenv("GATEWAY_INTERFACE"); putenv("REQUEST_METHOD"); } /* }}} */ ?> http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/tests/skipif.inc?view=markup&rev=1.1 Index: php-src/sapi/cgi/tests/skipif.inc +++ php-src/sapi/cgi/tests/skipif.inc <?php 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()) { die("skip CGI not found"); } ?>
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php