diff options
author | Zoe Slattery <zoe@php.net> | 2009-08-26 17:17:58 +0000 |
---|---|---|
committer | Zoe Slattery <zoe@php.net> | 2009-08-26 17:17:58 +0000 |
commit | 7effcd5f6c1cc2b1851bd0d5ef1ee06d89ba438a (patch) | |
tree | 036937e1cdb922ef28574653165cf8969f3e9e7b /ext/standard/tests | |
parent | 1a372313ca8e106b3816053ca9869282be01b6d1 (diff) | |
download | php-git-7effcd5f6c1cc2b1851bd0d5ef1ee06d89ba438a.tar.gz |
Test from 2009 testfest
Diffstat (limited to 'ext/standard/tests')
39 files changed, 1120 insertions, 0 deletions
diff --git a/ext/standard/tests/array/key_exists_basic.phpt b/ext/standard/tests/array/key_exists_basic.phpt new file mode 100644 index 0000000000..40d982da21 --- /dev/null +++ b/ext/standard/tests/array/key_exists_basic.phpt @@ -0,0 +1,15 @@ +--TEST-- +Test function key_exists() by calling it with its expected arguments +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php +echo "*** test key_exists() by calling it with its expected arguments ***\n"; +$a = array('bar' => 1); +var_dump(key_exists('bar', $a)); +var_dump(key_exists('foo', $a)); +--EXPECTF-- +*** test key_exists() by calling it with its expected arguments *** +bool(true) +bool(false) diff --git a/ext/standard/tests/array/key_exists_variation1.phpt b/ext/standard/tests/array/key_exists_variation1.phpt new file mode 100644 index 0000000000..94ea8d45f7 --- /dev/null +++ b/ext/standard/tests/array/key_exists_variation1.phpt @@ -0,0 +1,15 @@ +--TEST-- +Test function key_exists() by calling it with its expected arguments +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php +echo "*** test key_exists() by calling it with its expected arguments ***\n"; +$a = array('bar' => 1, 'foo' => array('bar' => 2, 'baz' => 3)); +var_dump(key_exists('baz', $a)); +var_dump(key_exists('baz', $a['foo'])); +--EXPECTF-- +*** test key_exists() by calling it with its expected arguments *** +bool(false) +bool(true) diff --git a/ext/standard/tests/array/key_exists_variation2.phpt b/ext/standard/tests/array/key_exists_variation2.phpt new file mode 100644 index 0000000000..5f5ab86a4f --- /dev/null +++ b/ext/standard/tests/array/key_exists_variation2.phpt @@ -0,0 +1,72 @@ +--TEST-- +Test function key_exists() by calling it with its expected arguments +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php +echo "*** test key_exists() by using mixed type of arrays ***\n"; + +// there is not a index = 0 element +$a = array(1 => 'bar', 'foo' => 'baz'); +var_dump(key_exists(0, $a)); + +echo "integer\n"; +// 1 has index = 0 +$b = array(1, 'foo' => 'baz'); +var_dump(key_exists(0, $b)); + +// 42 has index = 0, netherless its position is the latest +$c = array('foo' => 'baz', 42); +var_dump(key_exists(0, $c)); + +echo "string\n"; +// 'bar' has index = 0, netherless it is a string +$d = array('bar', 'foo' => 'baz'); +var_dump(key_exists(0, $d)); + +// 'baz' has index = 0, netherless its position is the latest +$e = array('foo' => 'baz', 'baz'); +var_dump(key_exists(0, $e)); + +echo "obj\n"; +class ObjectA +{ + public $foo = 'bar'; +} + +$obj = new ObjectA(); + +// object has index = 0, netherless its position is the latest +$f = array('foo' => 'baz', $obj); +var_dump(key_exists(0, $f)); + +// object has index = 0, netherless its position is the first +$g = array($obj, 'foo' => 'baz'); +var_dump(key_exists(0, $g)); + +echo "stream resource\n"; +// stream resource has index = 0, netherless its position is the first +$st = fopen('php://memory', '+r'); +$h = array($st, 'foo' => 'baz'); +var_dump(key_exists(0, $h)); + +// stream resource has index = 0, netherless its position is the latest +$i = array('foo' => 'baz', $st); +var_dump(key_exists(0, $i)); + +--EXPECTF-- +*** test key_exists() by using mixed type of arrays *** +bool(false) +integer +bool(true) +bool(true) +string +bool(true) +bool(true) +obj +bool(true) +bool(true) +stream resource +bool(true) +bool(true) diff --git a/ext/standard/tests/file/file_get_contents_error001.phpt b/ext/standard/tests/file/file_get_contents_error001.phpt new file mode 100644 index 0000000000..ced0da032c --- /dev/null +++ b/ext/standard/tests/file/file_get_contents_error001.phpt @@ -0,0 +1,18 @@ +--TEST-- +file_get_contents() test using offset parameter out of range +--CREDITS-- +"Blanche V.N." <valerie_nare@yahoo.fr> +"Sylvain R." <sracine@phpquebec.org> +--INI-- +display_errors=false +--SKIPIF-- +<?php + if (!function_exists("file_get_contents")) + die ("skip file_get_contents function is not found"); +?> +--FILE-- +<?php + var_dump(file_get_contents("http://checkip.dyndns.com",null,null,8000,1)); +?> +--EXPECT-- +bool(false) diff --git a/ext/standard/tests/file/file_get_contents_error002.phpt b/ext/standard/tests/file/file_get_contents_error002.phpt new file mode 100644 index 0000000000..47c7b9cd63 --- /dev/null +++ b/ext/standard/tests/file/file_get_contents_error002.phpt @@ -0,0 +1,18 @@ +--TEST-- +file_get_contents() test using negative parameter for length (last parameter) +--CREDITS-- +"Blanche V.N." <valerie_nare@yahoo.fr> +"Sylvain R." <sracine@phpquebec.org> +--INI-- +display_errors=false +--SKIPIF-- +<?php + if (!function_exists("file_get_contents")) + die ("skip file_get_contents function is not found"); +?> +--FILE-- +<?php + var_dump(file_get_contents("http://checkip.dyndns.com",null,null,0,-1)); +?> +--EXPECT-- +bool(false) diff --git a/ext/standard/tests/general_functions/get_cfg_var_variation2.phpt b/ext/standard/tests/general_functions/get_cfg_var_variation2.phpt new file mode 100644 index 0000000000..68495a13d9 --- /dev/null +++ b/ext/standard/tests/general_functions/get_cfg_var_variation2.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test function get_cfg_var() by substituting argument 1 with boolean values. +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--INI-- +session.use_cookies=0 +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with boolean values ***\n"; + + + +$variation_array = array( + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + ); + + +foreach ( $variation_array as $var ) { + var_dump(get_cfg_var( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with boolean values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/get_cfg_var_variation3.phpt b/ext/standard/tests/general_functions/get_cfg_var_variation3.phpt new file mode 100644 index 0000000000..d1fb5e7dda --- /dev/null +++ b/ext/standard/tests/general_functions/get_cfg_var_variation3.phpt @@ -0,0 +1,42 @@ +--TEST-- +Test function get_cfg_var() by substituting argument 1 with emptyUnsetUndefNull values. +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--INI-- +session.use_cookies=0 +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with emptyUnsetUndefNull values ***\n"; + + + +$unset_var = 10; +unset($unset_var); + +$variation_array = array( + 'unset var' => @$unset_var, + 'undefined var' => @$undefined_var, + 'empty string DQ' => "", + 'empty string SQ' => '', + 'uppercase NULL' => NULL, + 'lowercase null' => null + ); + + +foreach ( $variation_array as $var ) { + var_dump(get_cfg_var( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with emptyUnsetUndefNull values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/get_cfg_var_variation4.phpt b/ext/standard/tests/general_functions/get_cfg_var_variation4.phpt new file mode 100644 index 0000000000..8dac4f8a40 --- /dev/null +++ b/ext/standard/tests/general_functions/get_cfg_var_variation4.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test function get_cfg_var() by substituting argument 1 with float values. +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--INI-- +session.use_cookies=0 +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with float values ***\n"; + + + +$variation_array = array( + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float 12.3456789000e10' => 12.3456789000e10, + 'float -12.3456789000e10' => -12.3456789000e10, + 'float .5' => .5, + ); + + +foreach ( $variation_array as $var ) { + var_dump(get_cfg_var( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with float values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/get_cfg_var_variation5.phpt b/ext/standard/tests/general_functions/get_cfg_var_variation5.phpt new file mode 100644 index 0000000000..392abb32c5 --- /dev/null +++ b/ext/standard/tests/general_functions/get_cfg_var_variation5.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test function get_cfg_var() by substituting argument 1 with int values. +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--INI-- +session.use_cookies=0 +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with int values ***\n"; + + + +$variation_array = array ( + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -2345, + ); + + +foreach ( $variation_array as $var ) { + var_dump(get_cfg_var( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with int values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/get_cfg_var_variation7.phpt b/ext/standard/tests/general_functions/get_cfg_var_variation7.phpt new file mode 100644 index 0000000000..3b5b08c6d5 --- /dev/null +++ b/ext/standard/tests/general_functions/get_cfg_var_variation7.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test function get_cfg_var() by substituting argument 1 with string values. +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--INI-- +session.use_cookies=0 +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with unknown string values ***\n"; + + + +$heredoc = <<<EOT +hello world +EOT; + +$variation_array = array( + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc + ); + + +foreach ( $variation_array as $var ) { + var_dump(get_cfg_var( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with unknown string values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_basic.phpt b/ext/standard/tests/general_functions/getservbyname_basic.phpt new file mode 100755 index 0000000000..164e71afd4 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_basic.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test function getservbyport() by calling it more than or less than its expected arguments +--CREDITS-- +Italian PHP TestFest 2009 Cesena 19-20-21 june +Fabio Fabbrucci (fabbrucci@grupporetina.com) +Michele Orselli (mo@ideato.it) +Simone Gentili (sensorario@gmail.com) +--FILE-- +<?php + + $services = array('http', 'ftp', 'ssh', 'telnet', 'imap', 'smtp', 'nicname', 'gopher', 'finger', 'pop3', 'www'); + + foreach ($services as $service) { + $port = getservbyname($service, 'tcp'); + var_dump($port); + } + + +?> +--EXPECTF-- +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) diff --git a/ext/standard/tests/general_functions/getservbyname_variation10.phpt b/ext/standard/tests/general_functions/getservbyname_variation10.phpt new file mode 100755 index 0000000000..70aa567646 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation10.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test function getservbyname() by substituting argument 2 with emptyUnsetUndefNull values. +--FILE-- +<?php + + +echo "*** Test substituting argument 2 with emptyUnsetUndefNull values ***\n"; + +$service = "www"; + + +$unset_var = 10; +unset($unset_var); + +$variation_array = array( + 'unset var' => @$unset_var, + 'undefined var' => @$undefined_var, + 'empty string DQ' => "", + 'empty string SQ' => '', + 'uppercase NULL' => NULL, + 'lowercase null' => null, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $service, $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 2 with emptyUnsetUndefNull values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation11.phpt b/ext/standard/tests/general_functions/getservbyname_variation11.phpt new file mode 100755 index 0000000000..3c410c55b6 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation11.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test function getservbyname() by substituting argument 2 with float values. +--FILE-- +<?php + + +echo "*** Test substituting argument 2 with float values ***\n"; + +$service = "www"; + +$variation_array = array( + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float 12.3456789000e10' => 12.3456789000e10, + 'float -12.3456789000e10' => -12.3456789000e10, + 'float .5' => .5, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $service, $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 2 with float values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation12.phpt b/ext/standard/tests/general_functions/getservbyname_variation12.phpt new file mode 100755 index 0000000000..7e5323cca8 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation12.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test function getservbyname() by substituting argument 2 with int values. +--FILE-- +<?php + + +echo "*** Test substituting argument 2 with int values ***\n"; + +$service = "www"; + + +$variation_array = array ( + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -2345, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $service, $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 2 with int values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation14.phpt b/ext/standard/tests/general_functions/getservbyname_variation14.phpt new file mode 100755 index 0000000000..d93b53ece4 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation14.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test function getservbyname() by substituting argument 2 with string values. +--FILE-- +<?php + + +echo "*** Test substituting argument 2 with string values ***\n"; + +$service = "www"; + + +$heredoc = <<<EOT +hello world +EOT; + +$variation_array = array( + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $service, $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 2 with string values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation2.phpt b/ext/standard/tests/general_functions/getservbyname_variation2.phpt new file mode 100755 index 0000000000..877c1d12af --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation2.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test function getservbyname() by substituting argument 1 with boolean values. +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with boolean values ***\n"; + +$protocol = "tcp"; + + +$variation_array = array( + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $var , $protocol ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with boolean values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation3.phpt b/ext/standard/tests/general_functions/getservbyname_variation3.phpt new file mode 100755 index 0000000000..d34259d2a2 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation3.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test function getservbyname() by substituting argument 1 with emptyUnsetUndefNull values. +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with emptyUnsetUndefNull values ***\n"; + +$protocol = "tcp"; + + +$unset_var = 10; +unset($unset_var); + +$variation_array = array( + 'unset var' => @$unset_var, + 'undefined var' => @$undefined_var, + 'empty string DQ' => "", + 'empty string SQ' => '', + 'uppercase NULL' => NULL, + 'lowercase null' => null, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $var , $protocol ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with emptyUnsetUndefNull values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation4.phpt b/ext/standard/tests/general_functions/getservbyname_variation4.phpt new file mode 100755 index 0000000000..6033c94363 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation4.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test function getservbyname() by substituting argument 1 with float values. +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with float values ***\n"; + +$protocol = "tcp"; + + +$variation_array = array( + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float 12.3456789000e10' => 12.3456789000e10, + 'float -12.3456789000e10' => -12.3456789000e10, + 'float .5' => .5, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $var , $protocol ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with float values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation5.phpt b/ext/standard/tests/general_functions/getservbyname_variation5.phpt new file mode 100755 index 0000000000..1d3b8f6d74 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation5.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test function getservbyname() by substituting argument 1 with int values. +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with int values ***\n"; + +$protocol = "tcp"; + + +$variation_array = array ( + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -2345, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $var , $protocol ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with int values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation7.phpt b/ext/standard/tests/general_functions/getservbyname_variation7.phpt new file mode 100755 index 0000000000..a0e223c50d --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation7.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test function getservbyname() by substituting argument 1 with string values. +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with string values ***\n"; + +$protocol = "tcp"; + + +$heredoc = <<<EOT +hello world +EOT; + +$variation_array = array( + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $var , $protocol ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with string values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation9.phpt b/ext/standard/tests/general_functions/getservbyname_variation9.phpt new file mode 100755 index 0000000000..c1c231e148 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation9.phpt @@ -0,0 +1,28 @@ +--TEST-- +Test function getservbyname() by substituting argument 2 with boolean values. +--FILE-- +<?php + + +echo "*** Test substituting argument 2 with boolean values ***\n"; + +$service = "www"; + +$variation_array = array( + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $service, $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 2 with boolean values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyport_basic.phpt b/ext/standard/tests/general_functions/getservbyport_basic.phpt new file mode 100644 index 0000000000..c18c0b7731 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyport_basic.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test function getservbyport() by calling it more than or less than its expected arguments +--CREDITS-- +Italian PHP TestFest 2009 Cesena 19-20-21 june +Fabio Fabbrucci (fabbrucci@grupporetina.com) +Michele Orselli (mo@ideato.it) +Simone Gentili (sensorario@gmail.com) +--FILE-- +<?php + if(stristr(PHP_OS, "linux")) $file = "/etc/services"; + elseif(stristr(PHP_OS, "Darwin")) $file = "/etc/services"; + elseif(substr(PHP_OS,0,3) == "WIN") $file = "C:/WINDOWS/system32/drivers/etc/services"; + else die(PHP_OS. " unsupported"); + + if(file_exists($file)){ + var_dump(getservbyport( 80, "tcp" ) === "www"); + }else{ + var_dump(getservbyport(80, "tcp") === false); + } +?> +--EXPECTF-- +bool(true) diff --git a/ext/standard/tests/general_functions/proc_nice_basic.phpt b/ext/standard/tests/general_functions/proc_nice_basic.phpt new file mode 100644 index 0000000000..5a95756276 --- /dev/null +++ b/ext/standard/tests/general_functions/proc_nice_basic.phpt @@ -0,0 +1,27 @@ +--TEST-- +proc_nice() basic behaviour +--CREDITS-- +Italian PHP TestFest 2009 Cesena 19-20-21 june +Fabio Fabbrucci (fabbrucci@grupporetina.com) +Michele Orselli (mo@ideato.it) +Simone Gentili (sensorario@gmail.com) +--FILE-- +<?php + function getNice($id) + { + $res = shell_exec('ps -p ' . $id .' -o "%p %n"'); + preg_match('/^\s*\w+\s+\w+\s*(\d+)\s+(\d+)/m', $res, $matches); + if (count($matches) > 2) + return $matches[2]; + else + return -1; + } + $delta = 10; + $pid = getmypid(); + $niceBefore = getNice($pid); + proc_nice($delta); + $niceAfter = getNice($pid); + var_dump($niceBefore == ($niceAfter - $delta)); +?> +--EXPECTF-- +bool(true) diff --git a/ext/standard/tests/general_functions/proc_nice_error.phpt b/ext/standard/tests/general_functions/proc_nice_error.phpt new file mode 100644 index 0000000000..c50812c863 --- /dev/null +++ b/ext/standard/tests/general_functions/proc_nice_error.phpt @@ -0,0 +1,21 @@ +--TEST-- +Test function proc_nice() by calling it more than or less than its expected arguments +--FILE-- +<?php + + +echo "*** Test by calling method or function with incorrect numbers of arguments ***\n" + +$priority = + + +$extra_arg = + +var_dump(proc_nice( $priority, $extra_arg ) ); + +var_dump(proc_nice( ) ); + + +?> +--EXPECTF-- +Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in %s on line %d diff --git a/ext/standard/tests/general_functions/proc_nice_variation1.phpt b/ext/standard/tests/general_functions/proc_nice_variation1.phpt new file mode 100644 index 0000000000..b86155c4b2 --- /dev/null +++ b/ext/standard/tests/general_functions/proc_nice_variation1.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test function proc_nice() by substituting argument 1 with array values. +--CREDITS-- +Italian PHP TestFest 2009 Cesena 19-20-21 june +Fabio Fabbrucci (fabbrucci@grupporetina.com) +Michele Orselli (mo@ideato.it) +Simone Gentili (sensorario@gmail.com) +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with array values ***\n"; + + + +$index_array = array(1, 2, 3); +$assoc_array = array(1 => 'one', 2 => 'two'); + +$variation_array = array( + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + ); + + +foreach ( $variation_array as $var ) { + var_dump(proc_nice( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with array values *** + +Warning: proc_nice() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: proc_nice() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: proc_nice() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: proc_nice() expects parameter 1 to be long, array given in %s on line %d +bool(false) diff --git a/ext/standard/tests/general_functions/proc_nice_variation2.phpt b/ext/standard/tests/general_functions/proc_nice_variation2.phpt new file mode 100644 index 0000000000..620fe91447 --- /dev/null +++ b/ext/standard/tests/general_functions/proc_nice_variation2.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test function proc_nice() by substituting argument 1 with boolean values. +--CREDITS-- +Italian PHP TestFest 2009 Cesena 19-20-21 june +Fabio Fabbrucci (fabbrucci@grupporetina.com) +Michele Orselli (mo@ideato.it) +Simone Gentili (sensorario@gmail.com) +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with boolean values ***\n"; + + + +$variation_array = array( + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + ); + + +foreach ( $variation_array as $var ) { + var_dump(proc_nice( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with boolean values *** +bool(true) +bool(true) +bool(true) +bool(true) diff --git a/ext/standard/tests/general_functions/proc_nice_variation5.phpt b/ext/standard/tests/general_functions/proc_nice_variation5.phpt new file mode 100644 index 0000000000..d8325106ba --- /dev/null +++ b/ext/standard/tests/general_functions/proc_nice_variation5.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test function proc_nice() by substituting argument 1 with int values. +--CREDITS-- +Italian PHP TestFest 2009 Cesena 19-20-21 june +Fabio Fabbrucci (fabbrucci@grupporetina.com) +Michele Orselli (mo@ideato.it) +Simone Gentili (sensorario@gmail.com) +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with int values ***\n"; + + + +$variation_array = array ( + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -2345, + ); + + +foreach ( $variation_array as $var ) { + var_dump(proc_nice( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with int values *** +bool(true) +bool(true) +bool(true) + +Warning: proc_nice(): Only a super user may attempt to increase the priority of a process in %s on line %d +bool(false) diff --git a/ext/standard/tests/general_functions/proc_nice_variation6.phpt b/ext/standard/tests/general_functions/proc_nice_variation6.phpt new file mode 100644 index 0000000000..b4babd5930 --- /dev/null +++ b/ext/standard/tests/general_functions/proc_nice_variation6.phpt @@ -0,0 +1,52 @@ +--TEST-- +Test function proc_nice() by substituting argument 1 with object values. +--CREDITS-- +Italian PHP TestFest 2009 Cesena 19-20-21 june +Fabio Fabbrucci (fabbrucci@grupporetina.com) +Michele Orselli (mo@ideato.it) +Simone Gentili (sensorario@gmail.com) +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with object values ***\n"; + + + +function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { + if (error_reporting() != 0) { + // report non-silenced errors + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; + } +} +set_error_handler('test_error_handler'); + + + +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +$variation_array = array( + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + ); + + +foreach ( $variation_array as $var ) { + var_dump(proc_nice( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with object values *** +Error: 2 - proc_nice() expects parameter 1 to be long, object given, %s(%d) +bool(false) +Error: 2 - proc_nice() expects parameter 1 to be long, object given, %s(%d) +bool(false) diff --git a/ext/standard/tests/misc/time_sleep_until_basic.phpt b/ext/standard/tests/misc/time_sleep_until_basic.phpt new file mode 100644 index 0000000000..7f2f32d243 --- /dev/null +++ b/ext/standard/tests/misc/time_sleep_until_basic.phpt @@ -0,0 +1,14 @@ +--TEST-- +time_sleep_until() function - basic test for time_sleep_until() +--CREDITS-- +Manuel Baldassarri mb@ideato.it +Michele Orselli mo@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + $time = time() + 2; + time_sleep_until( $time ); + var_dump( time() >= $time ); +?> +--EXPECT-- +bool(true) diff --git a/ext/standard/tests/misc/time_sleep_until_error1.phpt b/ext/standard/tests/misc/time_sleep_until_error1.phpt new file mode 100644 index 0000000000..9752fd70e3 --- /dev/null +++ b/ext/standard/tests/misc/time_sleep_until_error1.phpt @@ -0,0 +1,13 @@ +--TEST-- +time_sleep_until() function - error test for time_sleep_until() +--CREDITS-- +Fabio Fabbrucci fabbrucci@grupporetina.com +Danilo Sanchi sanchi@grupporetina.com +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + var_dump(time_sleep_until(time()-1)); +?> +--EXPECTF-- +Warning: time_sleep_until(): Sleep until to time is less than current time in %s on line 2 +bool(false) diff --git a/ext/standard/tests/misc/time_sleep_until_error3.phpt b/ext/standard/tests/misc/time_sleep_until_error3.phpt new file mode 100644 index 0000000000..64489618ae --- /dev/null +++ b/ext/standard/tests/misc/time_sleep_until_error3.phpt @@ -0,0 +1,12 @@ +--TEST-- +time_sleep_until() function - error test for time_sleep_until() +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + var_dump(time_sleep_until()); +?> +--EXPECTF-- +Warning: time_sleep_until() expects exactly 1 parameter, 0 given in %s on line 2 +NULL diff --git a/ext/standard/tests/php_ini_loaded_file.phpt b/ext/standard/tests/php_ini_loaded_file.phpt new file mode 100644 index 0000000000..ab26953eac --- /dev/null +++ b/ext/standard/tests/php_ini_loaded_file.phpt @@ -0,0 +1,13 @@ +--TEST-- +Check the php_ini_loaded_file() function. No file is loaded in test, so false ins returned +--CREDITS-- +Sebastian Schürmann +sschuermann@chip.de +Testfest 2009 Munich +--FILE-- +<?php +var_dump(php_ini_loaded_file()); +?> +--EXPECT-- +bool(false) + diff --git a/ext/standard/tests/php_logo_guid.phpt b/ext/standard/tests/php_logo_guid.phpt new file mode 100644 index 0000000000..c644b2893b --- /dev/null +++ b/ext/standard/tests/php_logo_guid.phpt @@ -0,0 +1,13 @@ +--TEST-- +Check the output of the php_logo_guid() function +--CREDITS-- +Sebastian Schürmann +sschuermann@chip.de +Testfest 2009 Munich +--FILE-- +<?php +echo php_logo_guid(); +?> +--EXPECT-- +PHPE9568F34-D428-11d2-A769-00AA001ACF42 + diff --git a/ext/standard/tests/php_real_logo_guid.phpt b/ext/standard/tests/php_real_logo_guid.phpt new file mode 100644 index 0000000000..a9fa7d35d5 --- /dev/null +++ b/ext/standard/tests/php_real_logo_guid.phpt @@ -0,0 +1,12 @@ +--TEST-- +Testing the undocumented function php_real_logo_guid() +--CREDITS-- +Sebastian Schürmann +sschuermann@chip.de +Testfest 2009 Munich +--FILE-- +<?php +echo php_real_logo_guid(); +?> +--EXPECT-- +PHPE9568F34-D428-11d2-A769-00AA001ACF42 diff --git a/ext/standard/tests/strings/show_source_basic.phpt b/ext/standard/tests/strings/show_source_basic.phpt new file mode 100644 index 0000000000..cfd998fe96 --- /dev/null +++ b/ext/standard/tests/strings/show_source_basic.phpt @@ -0,0 +1,27 @@ +--TEST-- +Test function show_source() by calling it with its expected arguments, more test for highlight_file() +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php +echo "*** Test by calling method or function with its expected arguments ***\n"; +$foo = 'bar'; +$baz = "something ".$foo."\n"; + +if ( $foo == 'bar' ) +{ + $baz = 'baz'; +} + + /* some code here */ + +show_source(__FILE__); + +?> +--EXPECTF-- +*** Test by calling method or function with its expected arguments *** +<code><span style="color: #000000"> +<span style="color: #0000BB"><?php<br /></span><span style="color: #007700">echo </span><span style="color: #DD0000">"*** Test by calling method or function with its expected arguments ***\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$foo </span><span style="color: #007700">= </span><span style="color: #DD0000">'bar'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$baz </span><span style="color: #007700">= </span><span style="color: #DD0000">"something "</span><span style="color: #007700">.</span><span style="color: #0000BB">$foo</span><span style="color: #007700">.</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br />if ( </span><span style="color: #0000BB">$foo </span><span style="color: #007700">== </span><span style="color: #DD0000">'bar' </span><span style="color: #007700">) <br />{<br /> </span><span style="color: #0000BB">$baz </span><span style="color: #007700">= </span><span style="color: #DD0000">'baz'</span><span style="color: #007700">;<br />}<br /><br /> </span><span style="color: #FF8000">/* some code here */<br /> <br /></span><span style="color: #0000BB">show_source</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?><br /></span> +</span> +</code> diff --git a/ext/standard/tests/strings/show_source_variation1.phpt b/ext/standard/tests/strings/show_source_variation1.phpt new file mode 100644 index 0000000000..a9993ed457 --- /dev/null +++ b/ext/standard/tests/strings/show_source_variation1.phpt @@ -0,0 +1,28 @@ +--TEST-- +Test function show_source() by calling it with its expected arguments and php output, more test for highlight_file() +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php +echo "*** Test by calling method or function with its expected arguments and php output ***\n"; +$foo = 'bar'; +$baz = "something ".$foo."\n"; + +if ( $foo == 'bar' ) +{ + $baz = "baz\n"; +} + + /* some code here */ +echo $baz; +show_source(__FILE__); +echo $foo; +?> +--EXPECTF-- +*** Test by calling method or function with its expected arguments and php output *** +baz +<code><span style="color: #000000"> +<span style="color: #0000BB"><?php<br /></span><span style="color: #007700">echo </span><span style="color: #DD0000">"*** Test by calling method or function with its expected arguments and php output ***\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$foo </span><span style="color: #007700">= </span><span style="color: #DD0000">'bar'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$baz </span><span style="color: #007700">= </span><span style="color: #DD0000">"something "</span><span style="color: #007700">.</span><span style="color: #0000BB">$foo</span><span style="color: #007700">.</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br />if ( </span><span style="color: #0000BB">$foo </span><span style="color: #007700">== </span><span style="color: #DD0000">'bar' </span><span style="color: #007700">) <br />{<br /> </span><span style="color: #0000BB">$baz </span><span style="color: #007700">= </span><span style="color: #DD0000">"baz\n"</span><span style="color: #007700">;<br />}<br /><br /> </span><span style="color: #FF8000">/* some code here */<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$baz</span><span style="color: #007700">; <br /></span><span style="color: #0000BB">show_source</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$foo</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?><br /></span> +</span> +</code>bar diff --git a/ext/standard/tests/strings/show_source_variation2.phpt b/ext/standard/tests/strings/show_source_variation2.phpt new file mode 100644 index 0000000000..06ef66c2d2 --- /dev/null +++ b/ext/standard/tests/strings/show_source_variation2.phpt @@ -0,0 +1,27 @@ +--TEST-- +Test function show_source() by calling it with its expected arguments and output to variable, more test for highlight_file() +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php +echo "*** Test by calling method or function with its expected arguments and output to variable ***\n"; +$foo = 'bar'; +$baz = "something ".$foo."\n"; + +if ( $foo == 'bar' ) +{ + $baz = "baz\n"; +} + + /* some code here */ +$source = show_source(__FILE__, true); + +var_dump($source); +?> +--EXPECTF-- +*** Test by calling method or function with its expected arguments and output to variable *** +string(1987) "<code><span style="color: #000000"> +<span style="color: #0000BB"><?php<br /></span><span style="color: #007700">echo </span><span style="color: #DD0000">"*** Test by calling method or function with its expected arguments and output to variable ***\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$foo </span><span style="color: #007700">= </span><span style="color: #DD0000">'bar'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$baz </span><span style="color: #007700">= </span><span style="color: #DD0000">"something "</span><span style="color: #007700">.</span><span style="color: #0000BB">$foo</span><span style="color: #007700">.</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br />if ( </span><span style="color: #0000BB">$foo </span><span style="color: #007700">== </span><span style="color: #DD0000">'bar' </span><span style="color: #007700">) <br />{<br /> </span><span style="color: #0000BB">$baz </span><span style="color: #007700">= </span><span style="color: #DD0000">"baz\n"</span><span style="color: #007700">;<br />}<br /><br /> </span><span style="color: #FF8000">/* some code here */ <br /></span><span style="color: #0000BB">$source </span><span style="color: #007700">= </span><span style="color: #0000BB">show_source</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">, </span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$source</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?><br /></span> +</span> +</code>" diff --git a/ext/standard/tests/url/get_headers_error_001.phpt b/ext/standard/tests/url/get_headers_error_001.phpt new file mode 100644 index 0000000000..8d5fd11f60 --- /dev/null +++ b/ext/standard/tests/url/get_headers_error_001.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test get_headers() function : error conditions - wrong number of args +--CREDITS-- +June Henriksen <juneih@redpill-linpro.com> +#PHPTestFest2009 Norway 2009-06-09 \o/ +--FILE-- +<?php +/* Prototype : proto array get_headers(string url[, int format]) + * Description: Fetches all the headers sent by the server in response to a HTTP request + * Source code: ext/standard/url.c + * Alias to functions: + */ + +echo "*** Testing get_headers() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing get_headers() function with Zero arguments --\n"; +var_dump( get_headers() ); + +//Test get_headers with one more than the expected number of arguments +echo "\n-- Testing get_headers() function with more than expected no. of arguments --\n"; +$url = 'string_val'; +$format = 1; +$extra_arg = 10; +var_dump( get_headers($url, $format, $extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing get_headers() : error conditions *** + +-- Testing get_headers() function with Zero arguments -- + +Warning: get_headers() expects at least 1 parameter, 0 given in %s on line 12 +NULL + +-- Testing get_headers() function with more than expected no. of arguments -- + +Warning: get_headers() expects at most 2 parameters, 3 given in %s on line 19 +NULL +Done + + + diff --git a/ext/standard/tests/zend_logo_guid.phpt b/ext/standard/tests/zend_logo_guid.phpt new file mode 100644 index 0000000000..d26ed45e9e --- /dev/null +++ b/ext/standard/tests/zend_logo_guid.phpt @@ -0,0 +1,12 @@ +--TEST-- +Checking the zend_logo_guid() functio +--CREDITS-- +Sebastian Schürmann +sschuermann@chip.de +Testfest 2009 Munich +--FILE-- +<?php +echo zend_logo_guid(); +?> +--EXPECT-- +PHPE9568F35-D428-11d2-A769-00AA001ACF42 |