From: Antony Dovgal Date: Tue, 17 Apr 2007 19:49:26 +0000 (+0000) Subject: add tests for CGI X-Git-Tag: php-5.2.2RC2~65 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a0370cd797b1f4e5b46a6ca2631f373e30c61445;p=php add tests for CGI --- diff --git a/run-tests.php b/run-tests.php index c894fa95bd..22528c0823 100755 --- a/run-tests.php +++ b/run-tests.php @@ -534,7 +534,7 @@ $exts_skipped = 0; $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; diff --git a/sapi/cgi/tests/001.phpt b/sapi/cgi/tests/001.phpt new file mode 100644 index 0000000000..74c694f7c0 --- /dev/null +++ b/sapi/cgi/tests/001.phpt @@ -0,0 +1,22 @@ +--TEST-- +version string +--SKIPIF-- + +--FILE-- + +--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 diff --git a/sapi/cgi/tests/002.phpt b/sapi/cgi/tests/002.phpt new file mode 100644 index 0000000000..66e2424f28 --- /dev/null +++ b/sapi/cgi/tests/002.phpt @@ -0,0 +1,52 @@ +--TEST-- +defining INI options with -d +--SKIPIF-- + +--FILE-- +'); + +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, ''); + +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 diff --git a/sapi/cgi/tests/003.phpt b/sapi/cgi/tests/003.phpt new file mode 100644 index 0000000000..0da3ca8602 --- /dev/null +++ b/sapi/cgi/tests/003.phpt @@ -0,0 +1,62 @@ +--TEST-- +strip comments and whitespace with -w +--SKIPIF-- + +--FILE-- + +'; + +file_put_contents($filename, $code); + +var_dump(`$php -n -w "$filename"`); +var_dump(`$php -n -w "wrong"`); +var_dump(`echo "" | $php -n -w`); + +@unlink($filename); + +echo "Done\n"; +?> +--EXPECTF-- +string(%d) "X-Powered-By: PHP/%s +Content-type: text/html + + + +" +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 + + +" +Done diff --git a/sapi/cgi/tests/004.phpt b/sapi/cgi/tests/004.phpt new file mode 100644 index 0000000000..c841b68e04 --- /dev/null +++ b/sapi/cgi/tests/004.phpt @@ -0,0 +1,43 @@ +--TEST-- +execute a file with -f +--SKIPIF-- + +--FILE-- + +'; + +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) " +
+Fatal error: Cannot access private property test::$pri in %s004.test.php on line 8
+" +string(25) "No input file specified. +" +Done diff --git a/sapi/cgi/tests/005.phpt b/sapi/cgi/tests/005.phpt new file mode 100644 index 0000000000..6d82b0f311 --- /dev/null +++ b/sapi/cgi/tests/005.phpt @@ -0,0 +1,30 @@ +--TEST-- +using invalid combinations of cmdline options +--SKIPIF-- + +--FILE-- + +--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 diff --git a/sapi/cgi/tests/006.phpt b/sapi/cgi/tests/006.phpt new file mode 100644 index 0000000000..f0a6ee9c13 --- /dev/null +++ b/sapi/cgi/tests/006.phpt @@ -0,0 +1,60 @@ +--TEST-- +syntax check +--SKIPIF-- + +--FILE-- + +'; + +file_put_contents($filename, $code); + +var_dump(`"$php" -n -l "$filename"`); +var_dump(`"$php" -n -l some.unknown`); + +$code = ' + +'; + +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) "
+Parse error: syntax error, unexpected T_PRIVATE, expecting '{' in %s006.test.php on line 5
+Errors parsing %s006.test.php +" +Done diff --git a/sapi/cgi/tests/007.phpt b/sapi/cgi/tests/007.phpt new file mode 100644 index 0000000000..c0f8df1bff --- /dev/null +++ b/sapi/cgi/tests/007.phpt @@ -0,0 +1,22 @@ +--TEST-- +invalid arguments and error messages +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +string(25) "No input file specified. +" +string(31) "No syntax errors detected in - +" +Done diff --git a/sapi/cgi/tests/008.phpt b/sapi/cgi/tests/008.phpt new file mode 100644 index 0000000000..d541ca430d --- /dev/null +++ b/sapi/cgi/tests/008.phpt @@ -0,0 +1,54 @@ +--TEST-- +syntax highlighting +--SKIPIF-- + +--FILE-- + +'; + +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 + + +
<?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;
?>
+
+
" +string(%d) "Status: 404 +X-Powered-By: PHP/%s +Content-type: text/html + +No input file specified. +" +Done diff --git a/sapi/cgi/tests/include.inc b/sapi/cgi/tests/include.inc new file mode 100644 index 0000000000..2a87321499 --- /dev/null +++ b/sapi/cgi/tests/include.inc @@ -0,0 +1,57 @@ + diff --git a/sapi/cgi/tests/skipif.inc b/sapi/cgi/tests/skipif.inc new file mode 100644 index 0000000000..9da8b7934d --- /dev/null +++ b/sapi/cgi/tests/skipif.inc @@ -0,0 +1,17 @@ +