From c4dd7a1a684490673e25aaf4fabec5df138854c4 Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Thu, 14 Mar 2013 05:42:27 +0000 Subject: Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2. --- sapi/cli/tests/001.phpt | 19 +++++ sapi/cli/tests/002-win32.phpt | 22 ++++++ sapi/cli/tests/002.phpt | 22 ++++++ sapi/cli/tests/003-2.phpt | 25 ++++++ sapi/cli/tests/003.phpt | 32 ++++++++ sapi/cli/tests/004.phpt | 34 ++++++++ sapi/cli/tests/005.phpt | 104 ++++++++++++++++++++++++ sapi/cli/tests/006.phpt | 140 +++++++++++++++++++++++++++++++++ sapi/cli/tests/007.phpt | 52 ++++++++++++ sapi/cli/tests/008.phpt | 43 ++++++++++ sapi/cli/tests/009.phpt | 20 +++++ sapi/cli/tests/010-2.phpt | 35 +++++++++ sapi/cli/tests/010.phpt | 46 +++++++++++ sapi/cli/tests/011.phpt | 58 ++++++++++++++ sapi/cli/tests/012.phpt | 38 +++++++++ sapi/cli/tests/013.phpt | 34 ++++++++ sapi/cli/tests/014.phpt | 44 +++++++++++ sapi/cli/tests/015.phpt | 35 +++++++++ sapi/cli/tests/016.phpt | 130 ++++++++++++++++++++++++++++++ sapi/cli/tests/017.phpt | 106 +++++++++++++++++++++++++ sapi/cli/tests/018.phpt | 27 +++++++ sapi/cli/tests/019.phpt | 36 +++++++++ sapi/cli/tests/020.phpt | 32 ++++++++ sapi/cli/tests/021.phpt | 43 ++++++++++ sapi/cli/tests/022.inc | 14 ++++ sapi/cli/tests/022.phpt | 47 +++++++++++ sapi/cli/tests/bug43177.phpt | 82 +++++++++++++++++++ sapi/cli/tests/bug44564.phpt | 22 ++++++ sapi/cli/tests/bug61546.phpt | 31 ++++++++ sapi/cli/tests/bug61679.phpt | 43 ++++++++++ sapi/cli/tests/bug61977.phpt | 55 +++++++++++++ sapi/cli/tests/php_cli_server.inc | 62 +++++++++++++++ sapi/cli/tests/php_cli_server_001.phpt | 16 ++++ sapi/cli/tests/php_cli_server_002.phpt | 20 +++++ sapi/cli/tests/php_cli_server_003.phpt | 18 +++++ sapi/cli/tests/php_cli_server_004.phpt | 48 +++++++++++ sapi/cli/tests/php_cli_server_005.phpt | 71 +++++++++++++++++ sapi/cli/tests/php_cli_server_006.phpt | 42 ++++++++++ sapi/cli/tests/php_cli_server_007.phpt | 40 ++++++++++ sapi/cli/tests/php_cli_server_008.phpt | 68 ++++++++++++++++ sapi/cli/tests/php_cli_server_009.phpt | 93 ++++++++++++++++++++++ sapi/cli/tests/php_cli_server_010.phpt | 75 ++++++++++++++++++ sapi/cli/tests/php_cli_server_011.phpt | 41 ++++++++++ sapi/cli/tests/php_cli_server_012.phpt | 55 +++++++++++++ sapi/cli/tests/php_cli_server_013.phpt | 108 +++++++++++++++++++++++++ sapi/cli/tests/php_cli_server_014.phpt | 80 +++++++++++++++++++ sapi/cli/tests/php_cli_server_015.phpt | 49 ++++++++++++ sapi/cli/tests/php_cli_server_016.phpt | 46 +++++++++++ sapi/cli/tests/php_cli_server_017.phpt | 44 +++++++++++ sapi/cli/tests/php_cli_server_018.phpt | 44 +++++++++++ sapi/cli/tests/skipif.inc | 7 ++ 51 files changed, 2498 insertions(+) create mode 100644 sapi/cli/tests/001.phpt create mode 100644 sapi/cli/tests/002-win32.phpt create mode 100644 sapi/cli/tests/002.phpt create mode 100644 sapi/cli/tests/003-2.phpt create mode 100644 sapi/cli/tests/003.phpt create mode 100644 sapi/cli/tests/004.phpt create mode 100644 sapi/cli/tests/005.phpt create mode 100644 sapi/cli/tests/006.phpt create mode 100644 sapi/cli/tests/007.phpt create mode 100644 sapi/cli/tests/008.phpt create mode 100644 sapi/cli/tests/009.phpt create mode 100644 sapi/cli/tests/010-2.phpt create mode 100644 sapi/cli/tests/010.phpt create mode 100644 sapi/cli/tests/011.phpt create mode 100644 sapi/cli/tests/012.phpt create mode 100644 sapi/cli/tests/013.phpt create mode 100644 sapi/cli/tests/014.phpt create mode 100644 sapi/cli/tests/015.phpt create mode 100644 sapi/cli/tests/016.phpt create mode 100644 sapi/cli/tests/017.phpt create mode 100644 sapi/cli/tests/018.phpt create mode 100644 sapi/cli/tests/019.phpt create mode 100644 sapi/cli/tests/020.phpt create mode 100644 sapi/cli/tests/021.phpt create mode 100644 sapi/cli/tests/022.inc create mode 100644 sapi/cli/tests/022.phpt create mode 100644 sapi/cli/tests/bug43177.phpt create mode 100644 sapi/cli/tests/bug44564.phpt create mode 100644 sapi/cli/tests/bug61546.phpt create mode 100644 sapi/cli/tests/bug61679.phpt create mode 100644 sapi/cli/tests/bug61977.phpt create mode 100644 sapi/cli/tests/php_cli_server.inc create mode 100644 sapi/cli/tests/php_cli_server_001.phpt create mode 100644 sapi/cli/tests/php_cli_server_002.phpt create mode 100644 sapi/cli/tests/php_cli_server_003.phpt create mode 100644 sapi/cli/tests/php_cli_server_004.phpt create mode 100644 sapi/cli/tests/php_cli_server_005.phpt create mode 100644 sapi/cli/tests/php_cli_server_006.phpt create mode 100644 sapi/cli/tests/php_cli_server_007.phpt create mode 100644 sapi/cli/tests/php_cli_server_008.phpt create mode 100644 sapi/cli/tests/php_cli_server_009.phpt create mode 100644 sapi/cli/tests/php_cli_server_010.phpt create mode 100644 sapi/cli/tests/php_cli_server_011.phpt create mode 100644 sapi/cli/tests/php_cli_server_012.phpt create mode 100644 sapi/cli/tests/php_cli_server_013.phpt create mode 100644 sapi/cli/tests/php_cli_server_014.phpt create mode 100644 sapi/cli/tests/php_cli_server_015.phpt create mode 100644 sapi/cli/tests/php_cli_server_016.phpt create mode 100644 sapi/cli/tests/php_cli_server_017.phpt create mode 100644 sapi/cli/tests/php_cli_server_018.phpt create mode 100644 sapi/cli/tests/skipif.inc (limited to 'sapi/cli/tests') diff --git a/sapi/cli/tests/001.phpt b/sapi/cli/tests/001.phpt new file mode 100644 index 0000000..6fbd608 --- /dev/null +++ b/sapi/cli/tests/001.phpt @@ -0,0 +1,19 @@ +--TEST-- +version string +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +string(%d) "PHP %s (cli) (built: %s)%s +Copyright (c) 1997-20%d The PHP Group +Zend Engine v%s, Copyright (c) 1998-20%d Zend Technologies +" +Done diff --git a/sapi/cli/tests/002-win32.phpt b/sapi/cli/tests/002-win32.phpt new file mode 100644 index 0000000..5a00c67 --- /dev/null +++ b/sapi/cli/tests/002-win32.phpt @@ -0,0 +1,22 @@ +--TEST-- +running code with -r +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +string(18) "string(5) "hello" +" +Done diff --git a/sapi/cli/tests/002.phpt b/sapi/cli/tests/002.phpt new file mode 100644 index 0000000..be2b633 --- /dev/null +++ b/sapi/cli/tests/002.phpt @@ -0,0 +1,22 @@ +--TEST-- +running code with -r +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +string(18) "string(5) "hello" +" +Done diff --git a/sapi/cli/tests/003-2.phpt b/sapi/cli/tests/003-2.phpt new file mode 100644 index 0000000..2ed9b07 --- /dev/null +++ b/sapi/cli/tests/003-2.phpt @@ -0,0 +1,25 @@ +--TEST-- +defining INI options with -d (as 2nd arg) +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +string(16) "string(3) "111" +" +string(16) "string(3) "500" +" +===DONE=== diff --git a/sapi/cli/tests/003.phpt b/sapi/cli/tests/003.phpt new file mode 100644 index 0000000..d62360e --- /dev/null +++ b/sapi/cli/tests/003.phpt @@ -0,0 +1,32 @@ +--TEST-- +defining INI options with -d +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +string(16) "string(3) "111" +" +string(16) "string(3) "500" +" +string(16) "string(3) "555" +" +string(40) "string(3) "555" +string(10) "/test/path" +" +Done diff --git a/sapi/cli/tests/004.phpt b/sapi/cli/tests/004.phpt new file mode 100644 index 0000000..378515d --- /dev/null +++ b/sapi/cli/tests/004.phpt @@ -0,0 +1,34 @@ +--TEST-- +show information about function +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +string(45) "Exception: Function unknown() does not exist +" +string(42) "Exception: Function echo() does not exist +" +string(119) "Function [ function phpinfo ] { + + - Parameters [1] { + Parameter #0 [ $what ] + } +} + +" +Done diff --git a/sapi/cli/tests/005.phpt b/sapi/cli/tests/005.phpt new file mode 100644 index 0000000..84b0f98 --- /dev/null +++ b/sapi/cli/tests/005.phpt @@ -0,0 +1,104 @@ +--TEST-- +show information about class +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +string(40) "Exception: Class unknown does not exist +" +string(183) "Class [ class stdClass ] { + + - Constants [0] { + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [0] { + } + + - Methods [0] { + } +} + +" +string(1355) "Class [ class Exception ] { + + - Constants [0] { + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [7] { + Property [ protected $message ] + Property [ private $string ] + Property [ protected $code ] + Property [ protected $file ] + Property [ protected $line ] + Property [ private $trace ] + Property [ private $previous ] + } + + - Methods [10] { + Method [ final private method __clone ] { + } + + Method [ public method __construct ] { + + - Parameters [3] { + Parameter #0 [ $message ] + Parameter #1 [ $code ] + Parameter #2 [ $previous ] + } + } + + Method [ final public method getMessage ] { + } + + Method [ final public method getCode ] { + } + + Method [ final public method getFile ] { + } + + Method [ final public method getLine ] { + } + + Method [ final public method getTrace ] { + } + + Method [ final public method getPrevious ] { + } + + Method [ final public method getTraceAsString ] { + } + + Method [ public method __toString ] { + } + } +} + +" +Done diff --git a/sapi/cli/tests/006.phpt b/sapi/cli/tests/006.phpt new file mode 100644 index 0000000..3d5c916 --- /dev/null +++ b/sapi/cli/tests/006.phpt @@ -0,0 +1,140 @@ +--TEST-- +show information about extension +--SKIPIF-- + +--INI-- +date.timezone= +--FILE-- + +--EXPECTF-- +string(44) "Exception: Extension unknown does not exist +" +string(37) "Exception: Extension does not exist +" +string(%d) "Extension [ extension #%d pcre version ] { + + - INI { + Entry [ pcre.backtrack_limit ] + Current = '%d' + } + Entry [ pcre.recursion_limit ] + Current = '%d' + } + } + + - Constants [14] { + Constant [ integer PREG_PATTERN_ORDER ] { 1 } + Constant [ integer PREG_SET_ORDER ] { 2 } + Constant [ integer PREG_OFFSET_CAPTURE ] { 256 } + Constant [ integer PREG_SPLIT_NO_EMPTY ] { 1 } + Constant [ integer PREG_SPLIT_DELIM_CAPTURE ] { 2 } + Constant [ integer PREG_SPLIT_OFFSET_CAPTURE ] { 4 } + Constant [ integer PREG_GREP_INVERT ] { 1 } + Constant [ integer PREG_NO_ERROR ] { 0 } + Constant [ integer PREG_INTERNAL_ERROR ] { 1 } + Constant [ integer PREG_BACKTRACK_LIMIT_ERROR ] { 2 } + Constant [ integer PREG_RECURSION_LIMIT_ERROR ] { 3 } + Constant [ integer PREG_BAD_UTF8_ERROR ] { 4 } + Constant [ integer PREG_BAD_UTF8_OFFSET_ERROR ] { 5 } + Constant [ string PCRE_VERSION ] { %s } + } + + - Functions { + Function [ function preg_match ] { + + - Parameters [5] { + Parameter #0 [ $pattern ] + Parameter #1 [ $subject ] + Parameter #2 [ &$subpatterns ] + Parameter #3 [ $flags ] + Parameter #4 [ $offset ] + } + } + Function [ function preg_match_all ] { + + - Parameters [5] { + Parameter #0 [ $pattern ] + Parameter #1 [ $subject ] + Parameter #2 [ &$subpatterns ] + Parameter #3 [ $flags ] + Parameter #4 [ $offset ] + } + } + Function [ function preg_replace ] { + + - Parameters [5] { + Parameter #0 [ $regex ] + Parameter #1 [ $replace ] + Parameter #2 [ $subject ] + Parameter #3 [ $limit ] + Parameter #4 [ &$count ] + } + } + Function [ function preg_replace_callback ] { + + - Parameters [5] { + Parameter #0 [ $regex ] + Parameter #1 [ $callback ] + Parameter #2 [ $subject ] + Parameter #3 [ $limit ] + Parameter #4 [ &$count ] + } + } + Function [ function preg_filter ] { + + - Parameters [5] { + Parameter #0 [ $regex ] + Parameter #1 [ $replace ] + Parameter #2 [ $subject ] + Parameter #3 [ $limit ] + Parameter #4 [ &$count ] + } + } + Function [ function preg_split ] { + + - Parameters [4] { + Parameter #0 [ $pattern ] + Parameter #1 [ $subject ] + Parameter #2 [ $limit ] + Parameter #3 [ $flags ] + } + } + Function [ function preg_quote ] { + + - Parameters [2] { + Parameter #0 [ $str ] + Parameter #1 [ $delim_char ] + } + } + Function [ function preg_grep ] { + + - Parameters [3] { + Parameter #0 [ $regex ] + Parameter #1 [ $input ] + Parameter #2 [ $flags ] + } + } + Function [ function preg_last_error ] { + + - Parameters [0] { + } + } + } +} + +" +Done diff --git a/sapi/cli/tests/007.phpt b/sapi/cli/tests/007.phpt new file mode 100644 index 0000000..0bf4070 --- /dev/null +++ b/sapi/cli/tests/007.phpt @@ -0,0 +1,52 @@ +--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(81) " + +" +string(33) "Could not open input file: wrong +" +string(43) " +" +Done diff --git a/sapi/cli/tests/008.phpt b/sapi/cli/tests/008.phpt new file mode 100644 index 0000000..e14338f --- /dev/null +++ b/sapi/cli/tests/008.phpt @@ -0,0 +1,43 @@ +--TEST-- +execute a file with -f +--SKIPIF-- + +--FILE-- + +'; + +file_put_contents($filename, $code); + +var_dump(`$php -n -f "$filename"`); +var_dump(`$php -n -f "wrong"`); + +@unlink($filename); + +echo "Done\n"; +?> +--EXPECTF-- +string(%d) " + +Fatal error: Cannot access private property test::$pri in %s on line %d +" +string(33) "Could not open input file: wrong +" +Done diff --git a/sapi/cli/tests/009.phpt b/sapi/cli/tests/009.phpt new file mode 100644 index 0000000..33f859f --- /dev/null +++ b/sapi/cli/tests/009.phpt @@ -0,0 +1,20 @@ +--TEST-- +using invalid combinations of cmdline options +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +string(57) "Either execute direct code, process stdin or use a file. +" +string(57) "Either execute direct code, process stdin or use a file. +" +Done diff --git a/sapi/cli/tests/010-2.phpt b/sapi/cli/tests/010-2.phpt new file mode 100644 index 0000000..bd33d2c --- /dev/null +++ b/sapi/cli/tests/010-2.phpt @@ -0,0 +1,35 @@ +--TEST-- +executing a code with -R +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +string(21) "int(1) +int(1) +int(1) +" +Done diff --git a/sapi/cli/tests/010.phpt b/sapi/cli/tests/010.phpt new file mode 100644 index 0000000..77c76c1 --- /dev/null +++ b/sapi/cli/tests/010.phpt @@ -0,0 +1,46 @@ +--TEST-- +executing a file with -F +--SKIPIF-- + +--FILE-- + +'; + +file_put_contents($filename, $code); + +$txt = ' +test +hello'; + +file_put_contents($filename_txt, $txt); + +var_dump(`cat "$filename_txt" | "$php" -n -F "$filename"`); + +?> +===DONE=== +--CLEAN-- + +--EXPECTF-- +string(25) " +string(10) "test +hello" +" +===DONE=== diff --git a/sapi/cli/tests/011.phpt b/sapi/cli/tests/011.phpt new file mode 100644 index 0000000..6154693 --- /dev/null +++ b/sapi/cli/tests/011.phpt @@ -0,0 +1,58 @@ +--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`); + +@unlink($filename); + +echo "Done\n"; +?> +--EXPECTF-- +string(%d) "No syntax errors detected in %s011.test.php +" +string(40) "Could not open input file: some.unknown +" +string(%d) " +Parse error: %s expecting %s{%s in %s on line %d +Errors parsing %s011.test.php +" +Done diff --git a/sapi/cli/tests/012.phpt b/sapi/cli/tests/012.phpt new file mode 100644 index 0000000..c1e4f6a --- /dev/null +++ b/sapi/cli/tests/012.phpt @@ -0,0 +1,38 @@ +--TEST-- +invalid arguments and error messages +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +string(32) "You can use -R or -F only once. +" +string(32) "You can use -R or -F only once. +" +string(32) "You can use -R or -F only once. +" +string(32) "You can use -R or -F only once. +" +string(26) "You can use -f only once. +" +string(26) "You can use -B only once. +" +string(26) "You can use -E only once. +" +string(26) "You can use -r only once. +" +Done diff --git a/sapi/cli/tests/013.phpt b/sapi/cli/tests/013.phpt new file mode 100644 index 0000000..99bfe5e --- /dev/null +++ b/sapi/cli/tests/013.phpt @@ -0,0 +1,34 @@ +--TEST-- +running PHP code before and after processing input lines with -B and -E +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +string(18) "string(5) "start" +" +string(16) "string(3) "end" +" +string(34) "string(5) "start" +string(3) "end" +" +Done diff --git a/sapi/cli/tests/014.phpt b/sapi/cli/tests/014.phpt new file mode 100644 index 0000000..e8c5203 --- /dev/null +++ b/sapi/cli/tests/014.phpt @@ -0,0 +1,44 @@ +--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(1478) " +
<?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(35) "Could not open input file: unknown +" +Done diff --git a/sapi/cli/tests/015.phpt b/sapi/cli/tests/015.phpt new file mode 100644 index 0000000..ab5918b --- /dev/null +++ b/sapi/cli/tests/015.phpt @@ -0,0 +1,35 @@ +--TEST-- +CLI long options +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +PHP %d.%d.%d%s(cli) (built: %s)%s +Array +( + [0] => - + [1] => foo + [2] => bar + [3] => baz +) + +PHP %d.%d.%d%s(cli) (built: %s)%s +Usage: %s [options] [-f] [--] [args...] +Done diff --git a/sapi/cli/tests/016.phpt b/sapi/cli/tests/016.phpt new file mode 100644 index 0000000..31c1a40 --- /dev/null +++ b/sapi/cli/tests/016.phpt @@ -0,0 +1,130 @@ +--TEST-- +CLI -a and readline +--SKIPIF-- + +--FILE-- + $code) { + echo "\n--------------\nSnippet no. $key:\n--------------\n"; + $code = escapeshellarg($code); + echo `echo $code | "$php" -a`, "\n"; +} + +echo "\nDone\n"; +?> +--XFAIL-- +https://bugs.php.net/bug.php?id=55496 +--EXPECTF-- +-------------- +Snippet no. 1: +-------------- +Interactive shell + +php > echo 'Hello world'; +Hello world +php > exit + + +-------------- +Snippet no. 2: +-------------- +Interactive shell + +php > echo 'multine +php ' single +php ' quote'; +multine +single +quote +php > exit + + +-------------- +Snippet no. 3: +-------------- +Interactive shell + +php > echo << Here +<<< > comes +<<< > the +<<< > doc +<<< > HEREDOC; +Here +comes +the +doc +php > + +-------------- +Snippet no. 4: +-------------- +Interactive shell + +php > if (0) { +php { echo "I'm not there"; +php { } +php > echo "Done"; +Done +php > + +-------------- +Snippet no. 5: +-------------- +Interactive shell + +php > function a_function_with_some_name() { +php { echo "I was called!"; +php { } +php > a_function_with_some_name(); +I was called! +php > + +Done diff --git a/sapi/cli/tests/017.phpt b/sapi/cli/tests/017.phpt new file mode 100644 index 0000000..efaf977 --- /dev/null +++ b/sapi/cli/tests/017.phpt @@ -0,0 +1,106 @@ +--TEST-- +CLI -a and libedit +--SKIPIF-- + +--FILE-- + $code) { + echo "\n--------------\nSnippet no. $key:\n--------------\n"; + $code = escapeshellarg($code); + echo `echo $code | "$php" -a`, "\n"; +} + +echo "\nDone\n"; +?> +--EXPECTF-- +-------------- +Snippet no. 1: +-------------- +Interactive shell + +Hello world + + +-------------- +Snippet no. 2: +-------------- +Interactive shell + +multine +single +quote + + +-------------- +Snippet no. 3: +-------------- +Interactive shell + +Here +comes +the +doc + + +-------------- +Snippet no. 4: +-------------- +Interactive shell + +Done + + +-------------- +Snippet no. 5: +-------------- +Interactive shell + + +Parse error: syntax error, unexpected ')' in php shell code on line 1 + + +Done diff --git a/sapi/cli/tests/018.phpt b/sapi/cli/tests/018.phpt new file mode 100644 index 0000000..56921bd --- /dev/null +++ b/sapi/cli/tests/018.phpt @@ -0,0 +1,27 @@ +--TEST-- +CLI php -m +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +[PHP Modules] +%a +pcre +%a + +[Zend Modules] +%aDone diff --git a/sapi/cli/tests/019.phpt b/sapi/cli/tests/019.phpt new file mode 100644 index 0000000..c98155d --- /dev/null +++ b/sapi/cli/tests/019.phpt @@ -0,0 +1,36 @@ +--TEST-- +CLI php -i +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +phpinfo() +PHP Version => %s +%a +PHP License +This program is free software; you can redistribute it and/or modify +it under the terms of the PHP License as published by the PHP Group +and included in the distribution in the file: LICENSE + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +If you did not receive a copy of the PHP license, or have any +questions about PHP licensing, please contact license@php.net. + +Done diff --git a/sapi/cli/tests/020.phpt b/sapi/cli/tests/020.phpt new file mode 100644 index 0000000..62be4ba --- /dev/null +++ b/sapi/cli/tests/020.phpt @@ -0,0 +1,32 @@ +--TEST-- +CLI php --ri +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Extension 'this_extension_does_not_exist_568537753423' not present. + +standard + +%a + +Directive => Local Value => Master Value +%a + +Done + diff --git a/sapi/cli/tests/021.phpt b/sapi/cli/tests/021.phpt new file mode 100644 index 0000000..2ddd688 --- /dev/null +++ b/sapi/cli/tests/021.phpt @@ -0,0 +1,43 @@ +--TEST-- +CLI shell shebang +--SKIPIF-- + 127) { + die ("skip shebang is too long, see http://www.in-ulm.de/~mascheck/various/shebang/#results"); +} +?> +--FILE-- +\n". + "adeus\n"; + +file_put_contents($filename, $script); +chmod($filename, 0777); + +echo `$filename`; + +echo "\nDone\n"; +?> +--CLEAN-- + +--EXPECTF-- +ola +2 +adeus + +Done diff --git a/sapi/cli/tests/022.inc b/sapi/cli/tests/022.inc new file mode 100644 index 0000000..b77512f --- /dev/null +++ b/sapi/cli/tests/022.inc @@ -0,0 +1,14 @@ + diff --git a/sapi/cli/tests/022.phpt b/sapi/cli/tests/022.phpt new file mode 100644 index 0000000..0110220 --- /dev/null +++ b/sapi/cli/tests/022.phpt @@ -0,0 +1,47 @@ +--TEST-- +STDIN/OUT/ERR stream type +--SKIPIF-- + +--FILE-- + $socket, + 1 => STDOUT, + 2 => STDERR, +); +$pipes = array(); +$proc = proc_open("$php -n " . escapeshellarg($test_file), $desc, $pipes); +var_dump($proc); +if (!$proc) { + exit(1); +} + +$client_socket = stream_socket_client('unix://' . $socket_file); +var_dump($client_socket); +echo stream_get_contents($client_socket); +fclose($client_socket); + +proc_terminate($proc); +proc_close($proc); +unlink($socket_file); +?> +--EXPECTF-- +resource(%d) of type (stream) +resource(%d) of type (process) +resource(%d) of type (stream) +resource(%d) of type (stream) +resource(%d) of type (stream) diff --git a/sapi/cli/tests/bug43177.phpt b/sapi/cli/tests/bug43177.phpt new file mode 100644 index 0000000..36b5504 --- /dev/null +++ b/sapi/cli/tests/bug43177.phpt @@ -0,0 +1,82 @@ +--TEST-- +Bug #61977 Test exit code for various errors +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +HTTP/1.1 200 OK +Host: localhost +Connection: close +X-Powered-By: %s +Content-type: text/html + +OK +HTTP/1.0 500 Internal Server Error +Host: localhost +Connection: close +X-Powered-By: %s +Content-type: text/html + +HTTP/1.0 500 Internal Server Error +Host: localhost +Connection: close +X-Powered-By: %s +Content-type: text/html + +HTTP/1.0 500 Internal Server Error +Host: localhost +Connection: close +X-Powered-By: %s +Content-type: text/html diff --git a/sapi/cli/tests/bug44564.phpt b/sapi/cli/tests/bug44564.phpt new file mode 100644 index 0000000..7dca62a --- /dev/null +++ b/sapi/cli/tests/bug44564.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #44564 (escapeshellarg removes UTF-8 multi-byte characters) +--SKIPIF-- + +--FILE-- +')); +var_dump(escapeshellarg('f~|;*Þ?')); +var_dump(escapeshellcmd('?€®đæ?')); +var_dump(escapeshellarg('aŊł€')); + +?> +--EXPECT-- +string(13) "f\{o\}\<€\>" +string(10) "'f~|;*Þ?'" +string(13) "\?€®đæ\?" +string(10) "'aŊł€'" diff --git a/sapi/cli/tests/bug61546.phpt b/sapi/cli/tests/bug61546.phpt new file mode 100644 index 0000000..071edb7 --- /dev/null +++ b/sapi/cli/tests/bug61546.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug #61546 (functions related to current script failed when chdir() in cli sapi) +--FILE-- + +--EXPECT-- +bool(true) +bool(true) +bool(true) diff --git a/sapi/cli/tests/bug61679.phpt b/sapi/cli/tests/bug61679.phpt new file mode 100644 index 0000000..819ce2f --- /dev/null +++ b/sapi/cli/tests/bug61679.phpt @@ -0,0 +1,43 @@ +--TEST-- +Bug #61679 (Error on non-standard HTTP methods) +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +HTTP/1.1 501 Not Implemented diff --git a/sapi/cli/tests/bug61977.phpt b/sapi/cli/tests/bug61977.phpt new file mode 100644 index 0000000..09a6ba6 --- /dev/null +++ b/sapi/cli/tests/bug61977.phpt @@ -0,0 +1,55 @@ +--TEST-- +Bug #61977 test CLI web-server support for Mime Type File extensions mapping +--SKIPIF-- + +--FILE-- +', true); + +/* + * If a Mime Type is added in php_cli_server.c, add it to this array and update + * the EXPECTF section accordingly + */ +$mimetypes = ['html', 'htm', 'svg', 'css', 'js', 'png', 'webm', 'ogv', 'ogg']; + +function test_mimetypes($mimetypes) { + foreach ($mimetypes as $mimetype) { + list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS); + $port = intval($port) ? : 80; + $fp = fsockopen($host, $port, $errno, $errstr, 0.5); + if (!$fp) die('Connect failed'); + file_put_contents(__DIR__ . "/foo.{$mimetype}", ''); + $header = <<
", $text; + } + } + @unlink(__DIR__ . "/foo.{$mimetype}"); + fclose($fp); + } + } +} + +test_mimetypes($mimetypes); +?> +--EXPECTF-- +foo.html => Content-Type: text/html; charset=UTF-8 +foo.htm => Content-Type: text/html; charset=UTF-8 +foo.svg => Content-Type: image/svg+xml +foo.css => Content-Type: text/css; charset=UTF-8 +foo.js => Content-Type: text/javascript; charset=UTF-8 +foo.png => Content-Type: image/png +foo.webm => Content-Type: video/webm +foo.ogv => Content-Type: video/ogg +foo.ogg => Content-Type: audio/ogg diff --git a/sapi/cli/tests/php_cli_server.inc b/sapi/cli/tests/php_cli_server.inc new file mode 100644 index 0000000..40c5361 --- /dev/null +++ b/sapi/cli/tests/php_cli_server.inc @@ -0,0 +1,62 @@ +'); + } + + $descriptorspec = array( + 0 => STDIN, + 1 => STDOUT, + 2 => STDERR, + ); + + if (substr(PHP_OS, 0, 3) == 'WIN') { + $cmd = "{$php_executable} -t {$doc_root} -n -S " . PHP_CLI_SERVER_ADDRESS; + if (!$no_router) { + $cmd .= " {$router}"; + } + + $handle = proc_open(addslashes($cmd), $descriptorspec, $pipes, $doc_root, NULL, array("bypass_shell" => true, "suppress_errors" => true)); + } else { + $cmd = "exec {$php_executable} -t {$doc_root} -n -S " . PHP_CLI_SERVER_ADDRESS; + if (!$no_router) { + $cmd .= " {$router}"; + } + $cmd .= " 2>/dev/null"; + + $handle = proc_open($cmd, $descriptorspec, $pipes, $doc_root); + } + + // note: even when server prints 'Listening on localhost:8964...Press Ctrl-C to quit.' + // it might not be listening yet...need to wait until fsockopen() call returns + $i = 0; + while (($i++ < 30) && !($fp = @fsockopen(PHP_CLI_SERVER_HOSTNAME, PHP_CLI_SERVER_PORT))) { + usleep(10000); + } + + if ($fp) { + fclose($fp); + } + + register_shutdown_function( + function($handle) use($router) { + proc_terminate($handle); + @unlink(__DIR__ . "/{$router}"); + }, + $handle + ); + // don't bother sleeping, server is already up + // server can take a variable amount of time to be up, so just sleeping a guessed amount of time + // does not work. this is why tests sometimes pass and sometimes fail. to get a reliable pass + // sleeping doesn't work. +} +?> + diff --git a/sapi/cli/tests/php_cli_server_001.phpt b/sapi/cli/tests/php_cli_server_001.phpt new file mode 100644 index 0000000..3f1083e --- /dev/null +++ b/sapi/cli/tests/php_cli_server_001.phpt @@ -0,0 +1,16 @@ +--TEST-- +basic function +--INI-- +allow_url_fopen=1 +--SKIPIF-- + +--FILE-- + +--EXPECT-- +string(11) "Hello world" diff --git a/sapi/cli/tests/php_cli_server_002.phpt b/sapi/cli/tests/php_cli_server_002.phpt new file mode 100644 index 0000000..93151c1 --- /dev/null +++ b/sapi/cli/tests/php_cli_server_002.phpt @@ -0,0 +1,20 @@ +--TEST-- +$_SERVER variable +--INI-- +allow_url_fopen=1 +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +string(%d) "string(%d) "%stests" +string(%d) "PHP %s Development Server" +string(%d) "localhost" +string(%d) "8964" +" diff --git a/sapi/cli/tests/php_cli_server_003.phpt b/sapi/cli/tests/php_cli_server_003.phpt new file mode 100644 index 0000000..d1e95fe --- /dev/null +++ b/sapi/cli/tests/php_cli_server_003.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #55726 (Changing the working directory makes router script inaccessible) +--INI-- +allow_url_fopen=1 +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +string(4) "okey" +string(4) "okey" diff --git a/sapi/cli/tests/php_cli_server_004.phpt b/sapi/cli/tests/php_cli_server_004.phpt new file mode 100644 index 0000000..b61f886 --- /dev/null +++ b/sapi/cli/tests/php_cli_server_004.phpt @@ -0,0 +1,48 @@ +--TEST-- +Bug #55747 (request headers missed in $_SERVER) +--INI-- +allow_url_fopen=1 +--SKIPIF-- + +--FILE-- +$v) { if (!strncmp($k, "HTTP", 4)) var_dump( $k . ":" . $v); }'); + +list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS); +$port = intval($port)?:80; + +$fp = fsockopen($host, $port, $errno, $errstr, 0.5); +if (!$fp) { + die("connect failed"); +} + +if(fwrite($fp, <<
+--EXPECTF-- +HTTP/1.1 200 OK +Host: %s +Connection: close +X-Powered-By: PHP/%s +Content-type: text/html + +string(19) "HTTP_HOST:localhost" +string(21) "HTTP_USER_AGENT:dummy" +string(15) "HTTP_CUSTOM:foo" +string(32) "HTTP_REFERER:http://www.php.net/" diff --git a/sapi/cli/tests/php_cli_server_005.phpt b/sapi/cli/tests/php_cli_server_005.phpt new file mode 100644 index 0000000..ccc0f8f --- /dev/null +++ b/sapi/cli/tests/php_cli_server_005.phpt @@ -0,0 +1,71 @@ +--TEST-- +Post a file +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +HTTP/1.1 200 OK +Host: %s +Connection: close +X-Powered-By: PHP/%s +Content-type: text/html + +array(1) { + ["userfile"]=> + array(5) { + ["name"]=> + string(12) "laruence.txt" + ["type"]=> + string(10) "text/plain" + ["tmp_name"]=> + string(%d) "%s" + ["error"]=> + int(0) + ["size"]=> + int(26) + } +} diff --git a/sapi/cli/tests/php_cli_server_006.phpt b/sapi/cli/tests/php_cli_server_006.phpt new file mode 100644 index 0000000..09e7ab0 --- /dev/null +++ b/sapi/cli/tests/php_cli_server_006.phpt @@ -0,0 +1,42 @@ +--TEST-- +Bug #55755 (SegFault when outputting header WWW-Authenticate) +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +HTTP/1.1 200 OK +Host: %s +Connection: close +X-Powered-By: PHP/%s +Content-type: text/html + +string(3) "foo" +string(3) "bar" diff --git a/sapi/cli/tests/php_cli_server_007.phpt b/sapi/cli/tests/php_cli_server_007.phpt new file mode 100644 index 0000000..64d4df0 --- /dev/null +++ b/sapi/cli/tests/php_cli_server_007.phpt @@ -0,0 +1,40 @@ +--TEST-- +Bug #55758 (Digest Authenticate missed in 5.4) +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +HTTP/1.1 401 Unauthorized +Host: %s +Connection: close +X-Powered-By: PHP/%s +WWW-Authenticate: Digest realm="foo",qop="auth",nonce="XXXXX",opaque="acbd18db4cc2f85cedef654fccc4a4d8" +Content-type: text/html diff --git a/sapi/cli/tests/php_cli_server_008.phpt b/sapi/cli/tests/php_cli_server_008.phpt new file mode 100644 index 0000000..2e68e24 --- /dev/null +++ b/sapi/cli/tests/php_cli_server_008.phpt @@ -0,0 +1,68 @@ +--TEST-- +SERVER_PROTOCOL header availability +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +HTTP/1.1 200 OK +Host: %s +Connection: close +X-Powered-By: PHP/%s +Content-type: text/html + +string(8) "HTTP/1.1" +HTTP/1.0 200 OK +Host: %s +Connection: close +X-Powered-By: PHP/%s +Content-type: text/html + +string(8) "HTTP/1.0" diff --git a/sapi/cli/tests/php_cli_server_009.phpt b/sapi/cli/tests/php_cli_server_009.phpt new file mode 100644 index 0000000..2beaeed --- /dev/null +++ b/sapi/cli/tests/php_cli_server_009.phpt @@ -0,0 +1,93 @@ +--TEST-- +PATH_INFO (relevant to #60112) +--DESCRIPTION-- +After this fix(#60112), previously 404 request like "localhost/foo/bar" +now could serve correctly with request_uri "index.php" and PATH_INFO "/foo/bar/" +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +HTTP/1.1 200 OK +Host: %s +Connection: close +X-Powered-By: PHP/%s +Content-type: text/html + +string(8) "/foo/bar" +HTTP/1.0 200 OK +Host: %s +Connection: close +X-Powered-By: PHP/%s +Content-type: text/html + +string(9) "/foo/bar/" +HTTP/1.0 404 Not Found diff --git a/sapi/cli/tests/php_cli_server_010.phpt b/sapi/cli/tests/php_cli_server_010.phpt new file mode 100644 index 0000000..2ef018b --- /dev/null +++ b/sapi/cli/tests/php_cli_server_010.phpt @@ -0,0 +1,75 @@ +--TEST-- +Bug #60180 ($_SERVER["PHP_SELF"] incorrect) +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +HTTP/1.1 200 OK +Host: %s +Connection: close +X-Powered-By: PHP/%s +Content-type: text/html + +string(18) "/index.php/foo/bar" +string(10) "/index.php" +string(8) "/foo/bar" +string(7) "foo=bar" +HTTP/1.0 200 OK +Host: %s +Connection: close +X-Powered-By: PHP/%s +Content-type: text/html + +string(19) "/index.php/foo/bar/" +string(10) "/index.php" +string(9) "/foo/bar/" +string(7) "foo=bar" diff --git a/sapi/cli/tests/php_cli_server_011.phpt b/sapi/cli/tests/php_cli_server_011.phpt new file mode 100644 index 0000000..a957a8e --- /dev/null +++ b/sapi/cli/tests/php_cli_server_011.phpt @@ -0,0 +1,41 @@ +--TEST-- +Bug #60180 ($_SERVER["PHP_SELF"] incorrect) +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +okey diff --git a/sapi/cli/tests/php_cli_server_012.phpt b/sapi/cli/tests/php_cli_server_012.phpt new file mode 100644 index 0000000..9a1e60c --- /dev/null +++ b/sapi/cli/tests/php_cli_server_012.phpt @@ -0,0 +1,55 @@ +--TEST-- +Bug #60159 (Router returns false, but POST is not passed to requested resource) +--SKIPIF-- + +--FILE-- +'); + +list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS); +$port = intval($port)?:80; + +$fp = fsockopen($host, $port, $errno, $errstr, 0.5); +if (!$fp) { + die("connect failed"); +} + +if(fwrite($fp, <<
+--EXPECTF-- +HTTP/1.1 200 OK +Host: %s +Connection: close +X-Powered-By: PHP/%s +Content-type: text/html + +Array +( + [a] => b +) +Array +( + [a] => b + [foo] => bar +) diff --git a/sapi/cli/tests/php_cli_server_013.phpt b/sapi/cli/tests/php_cli_server_013.phpt new file mode 100644 index 0000000..570798a --- /dev/null +++ b/sapi/cli/tests/php_cli_server_013.phpt @@ -0,0 +1,108 @@ +--TEST-- +No router, no script +--SKIPIF-- + +--FILE-- +(.*?)<\/style>/s", "", $output), "\n"; +fclose($fp); + + +$output = ''; +$fp = fsockopen($host, $port, $errno, $errstr, 0.5); +if (!$fp) { + die("connect failed"); +} + +if(fwrite($fp, <<
(.*?)<\/style>/s", "", $output), "\n"; +fclose($fp); + +$output = ''; +$fp = fsockopen($host, $port, $errno, $errstr, 0.5); +if (!$fp) { + die("connect failed"); +} + +if(fwrite($fp, <<
(.*?)<\/style>/s", "", $output), "\n"; +fclose($fp); +?> +--EXPECTF-- + +HTTP/1.1 404 Not Found +Host: %s +Connection: close +Content-Type: text/html; charset=UTF-8 +Content-Length: %d + +404 Not Found +

Not Found

The requested resource / was not found on this server.

+HTTP/1.1 404 Not Found +Host: %s +Connection: close +Content-Type: text/html; charset=UTF-8 +Content-Length: %d + +404 Not Found +

Not Found

The requested resource /main/style.css was not found on this server.

+HTTP/1.1 404 Not Found +Host: %s +Connection: close +Content-Type: text/html; charset=UTF-8 +Content-Length: %d + +404 Not Found +

Not Found

The requested resource /main/foo/bar was not found on this server.

+ diff --git a/sapi/cli/tests/php_cli_server_014.phpt b/sapi/cli/tests/php_cli_server_014.phpt new file mode 100644 index 0000000..f8a9905 --- /dev/null +++ b/sapi/cli/tests/php_cli_server_014.phpt @@ -0,0 +1,80 @@ +--TEST-- +Bug #60477: Segfault after two multipart/form-data POST requestes +--SKIPIF-- + +--FILE-- +(.*?)<\/style>/s", "", $output), "\n"; +fclose($fp); + +?> +--EXPECTF-- + +HTTP/1.1 200 OK +Host: %s +Connection: close +X-Powered-By: %s +Content-type: %s + +done +HTTP/1.1 404 Not Found +Host: %s +Connection: close +Content-Type: %s +Content-Length: %d + +404 Not Found +

Not Found

The requested resource /main/no-exists.php was not found on this server.

diff --git a/sapi/cli/tests/php_cli_server_015.phpt b/sapi/cli/tests/php_cli_server_015.phpt new file mode 100644 index 0000000..6fb0169 --- /dev/null +++ b/sapi/cli/tests/php_cli_server_015.phpt @@ -0,0 +1,49 @@ +--TEST-- +Bug #60523 (PHP Errors are not reported in browsers using built-in SAPI) +--SKIPIF-- + +--INI-- +display_errors=1 +--FILE-- +"); + +list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS); +$port = intval($port)?:80; +$output = ''; + +$fp = fsockopen($host, $port, $errno, $errstr, 0.5); +if (!$fp) { + die("connect failed"); +} + +if(fwrite($fp, <<
+--EXPECTF-- +HTTP/1.1 200 OK +Host: %s +Connection: close +X-Powered-By: PHP/%s +Content-type: text/html + +
+Fatal error: Call to undefined function non_exists_function() in %ssyntax_error.php on line %s
diff --git a/sapi/cli/tests/php_cli_server_016.phpt b/sapi/cli/tests/php_cli_server_016.phpt new file mode 100644 index 0000000..f15aff1 --- /dev/null +++ b/sapi/cli/tests/php_cli_server_016.phpt @@ -0,0 +1,46 @@ +--TEST-- +Bug #60591 (Memory leak when access a non-exists file) +--DESCRIPTION-- +this is an indirect test for bug 60591, since mem leak is reproted in the server side +and require php compiled with --enable-debug +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +HTTP/1.1 404 Not Found diff --git a/sapi/cli/tests/php_cli_server_017.phpt b/sapi/cli/tests/php_cli_server_017.phpt new file mode 100644 index 0000000..73530af --- /dev/null +++ b/sapi/cli/tests/php_cli_server_017.phpt @@ -0,0 +1,44 @@ +--TEST-- +Implement Req #60850 (Built in web server does not set $_SERVER['SCRIPT_FILENAME'] when using router) +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +HTTP/1.1 200 OK +Host: %s +Connection: close +X-Powered-By: %s +Content-type: text/html + +string(%d) "%sindex.php" diff --git a/sapi/cli/tests/php_cli_server_018.phpt b/sapi/cli/tests/php_cli_server_018.phpt new file mode 100644 index 0000000..deb9348 --- /dev/null +++ b/sapi/cli/tests/php_cli_server_018.phpt @@ -0,0 +1,44 @@ +--TEST-- +Implement Req #61679 (Support HTTP PATCH method) +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +HTTP/1.1 200 OK +Host: %s +Connection: close +X-Powered-By: %s +Content-type: text/html + +string(5) "PATCH" diff --git a/sapi/cli/tests/skipif.inc b/sapi/cli/tests/skipif.inc new file mode 100644 index 0000000..79e6c91 --- /dev/null +++ b/sapi/cli/tests/skipif.inc @@ -0,0 +1,7 @@ + -- cgit v1.2.1