tony2001 Fri Aug 10 13:27:05 2007 UTC Removed files: /php-src/ext/standard/tests/array extract.phpt
Modified files: /php-src/ext/standard/tests/array extract_error.phpt extract_variation1.phpt extract_variation2.phpt extract_variation3.phpt extract_variation4.phpt extract_variation5.phpt extract_variation6.phpt extract_variation7.phpt extract_variation8.phpt extract_variation9.phpt Log: split the test
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/extract_error.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/extract_error.phpt diff -u /dev/null php-src/ext/standard/tests/array/extract_error.phpt:1.2 --- /dev/null Fri Aug 10 13:27:05 2007 +++ php-src/ext/standard/tests/array/extract_error.phpt Fri Aug 10 13:27:05 2007 @@ -0,0 +1,85 @@ +--TEST-- +Test extract() function (error conditions) +--FILE-- +<?php + +/* Testing Error Conditions */ +echo "*** Testing Error Conditions ***\n"; + +/* Zero Arguments */ +var_dump( extract() ); + +/* Invalid second argument ( only 0-6 is valid) */ +$arr = array(1); +var_dump( extract($arr, -1 . "wddr") ); +var_dump( extract($arr, 7 , "wddr") ); + +/* scalar argument */ +$val = 1; +var_dump( extract($val) ); + +/* string argument */ +$str = "test"; +var_dump( extract($str) ); + +/* More than valid number of arguments i.e. 3 args */ +var_dump( extract($arr, EXTR_SKIP, "aa", "ee") ); + +/* Two Arguments, second as prefix but without prefix string as third argument */ +var_dump( extract($arr,EXTR_PREFIX_IF_EXISTS) ); + +echo "Done\n"; +?> + +--EXPECTF-- +*** Testing Error Conditions *** + +Warning: extract() expects at least 1 parameter, 0 given in %s on line %d +NULL + +Notice: A non well formed numeric value encountered in %s on line %d + +Warning: extract(): Invalid extract type in %s on line %d +NULL + +Warning: extract(): Invalid extract type in %s on line %d +NULL + +Warning: extract() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: extract() expects parameter 1 to be array, string given in %s on line %d +NULL + +Warning: extract() expects at most 3 parameters, 4 given in %s on line %d +NULL + +Warning: extract(): specified extract type requires the prefix parameter in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing Error Conditions *** + +Warning: extract() expects at least 1 parameter, 0 given in %s on line %d +NULL + +Notice: A non well formed numeric value encountered in %s on line %d + +Warning: extract(): Invalid extract type in %s on line %d +NULL + +Warning: extract(): Invalid extract type in %s on line %d +NULL + +Warning: extract() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: extract() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +Warning: extract() expects at most 3 parameters, 4 given in %s on line %d +NULL + +Warning: extract(): specified extract type requires the prefix parameter in %s on line %d +NULL +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/extract_variation1.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/extract_variation1.phpt diff -u /dev/null php-src/ext/standard/tests/array/extract_variation1.phpt:1.2 --- /dev/null Fri Aug 10 13:27:05 2007 +++ php-src/ext/standard/tests/array/extract_variation1.phpt Fri Aug 10 13:27:05 2007 @@ -0,0 +1,35 @@ +--TEST-- +Test extract() function (variation 1) +--FILE-- +<?php + +$val = 4; +$str = "John"; + +debug_zval_dump($val); +debug_zval_dump($str); + +/* Extracting Global Variables */ +var_dump(extract($GLOBALS, EXTR_REFS)); +debug_zval_dump($val); +debug_zval_dump($str); + +echo "\nDone"; +?> + +--EXPECTF-- +long(4) refcount(2) +string(4) "John" refcount(2) +int(%d) +long(4) refcount(2) +string(4) "John" refcount(2) + +Done +--UEXPECTF-- +long(4) refcount(2) +unicode(4) "John" { 004a 006f 0068 006e } refcount(2) +int(10) +long(4) refcount(2) +unicode(4) "John" { 004a 006f 0068 006e } refcount(2) + +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/extract_variation2.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/extract_variation2.phpt diff -u /dev/null php-src/ext/standard/tests/array/extract_variation2.phpt:1.2 --- /dev/null Fri Aug 10 13:27:05 2007 +++ php-src/ext/standard/tests/array/extract_variation2.phpt Fri Aug 10 13:27:05 2007 @@ -0,0 +1,69 @@ +--TEST-- +Test extract() function (variation 2) +--FILE-- +<?php + +/* various combinations of arrays to be used for the test */ +$mixed_array = array( + array(), + array( 1,2,3,4,5,6,7,8,9 ), + array( "One", "Two", "Three", "Four", "Five" ), +); + +$counter = 0; + +foreach ( $mixed_array as $sub_array ) { + echo "\n-- Iteration $counter --\n"; + $counter++; + + var_dump ( extract($sub_array)); /* Single Argument */ + + /* variations of two arguments */ + var_dump ( extract($sub_array, EXTR_OVERWRITE)); + var_dump ( extract($sub_array, EXTR_SKIP)); + var_dump ( extract($sub_array, EXTR_IF_EXISTS)); + + /* variations of three arguments with use of various extract types*/ + var_dump ( extract($sub_array, EXTR_PREFIX_INVALID, "ssd")); + var_dump ( extract($sub_array, EXTR_PREFIX_SAME, "sss")); + var_dump ( extract($sub_array, EXTR_PREFIX_ALL, "bb")); + var_dump ( extract($sub_array, EXTR_PREFIX_ALL, "")); // "_" taken as default prefix + var_dump ( extract($sub_array, EXTR_PREFIX_IF_EXISTS, "bb")); +} + +echo "Done\n"; +?> +--EXPECTF-- +-- Iteration 0 -- +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) + +-- Iteration 1 -- +int(0) +int(0) +int(0) +int(0) +int(9) +int(0) +int(9) +int(9) +int(0) + +-- Iteration 2 -- +int(0) +int(0) +int(0) +int(0) +int(5) +int(0) +int(5) +int(5) +int(0) +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/extract_variation3.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/extract_variation3.phpt diff -u /dev/null php-src/ext/standard/tests/array/extract_variation3.phpt:1.2 --- /dev/null Fri Aug 10 13:27:05 2007 +++ php-src/ext/standard/tests/array/extract_variation3.phpt Fri Aug 10 13:27:05 2007 @@ -0,0 +1,69 @@ +--TEST-- +Test extract() function (variation 3) +--FILE-- +<?php + +/* various combinations of arrays to be used for the test */ +$mixed_array = array( + array( 6, "six", 7, "seven", 8, "eight", 9, "nine" ), + array( "a" => "aaa", "A" => "AAA", "c" => "ccc", "d" => "ddd", "e" => "eee" ), + array( "1" => "one", "2" => "two", "3" => "three", "4" => "four", "5" => "five" ), +); + +$counter = 0; + +foreach ( $mixed_array as $sub_array ) { + echo "\n-- Iteration $counter --\n"; + $counter++; + + var_dump ( extract($sub_array)); /* Single Argument */ + + /* variations of two arguments */ + var_dump ( extract($sub_array, EXTR_OVERWRITE)); + var_dump ( extract($sub_array, EXTR_SKIP)); + var_dump ( extract($sub_array, EXTR_IF_EXISTS)); + + /* variations of three arguments with use of various extract types*/ + var_dump ( extract($sub_array, EXTR_PREFIX_INVALID, "ssd")); + var_dump ( extract($sub_array, EXTR_PREFIX_SAME, "sss")); + var_dump ( extract($sub_array, EXTR_PREFIX_ALL, "bb")); + var_dump ( extract($sub_array, EXTR_PREFIX_ALL, "")); // "_" taken as default prefix + var_dump ( extract($sub_array, EXTR_PREFIX_IF_EXISTS, "bb")); +} + +echo "Done\n"; +?> +--EXPECTF-- +-- Iteration 0 -- +int(0) +int(0) +int(0) +int(0) +int(8) +int(0) +int(8) +int(8) +int(0) + +-- Iteration 1 -- +int(5) +int(5) +int(0) +int(5) +int(5) +int(5) +int(5) +int(5) +int(5) + +-- Iteration 2 -- +int(0) +int(0) +int(0) +int(0) +int(5) +int(0) +int(5) +int(5) +int(0) +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/extract_variation4.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/extract_variation4.phpt diff -u /dev/null php-src/ext/standard/tests/array/extract_variation4.phpt:1.2 --- /dev/null Fri Aug 10 13:27:05 2007 +++ php-src/ext/standard/tests/array/extract_variation4.phpt Fri Aug 10 13:27:05 2007 @@ -0,0 +1,69 @@ +--TEST-- +Test extract() function (variation 4) +--FILE-- +<?php + +$mixed_array = array( + array( 1 => "one", 2 => "two", 3 => 7, 4 => "four", 5 => "five" ), + array( "f" => "fff", "1" => "one", 4 => 6, "" => "blank", 2.4 => "float", "F" => "FFF", + "blank" => "", 3.7 => 3.7, 5.4 => 7, 6 => 8.6, '5' => "Five", "4name" => "jonny", "a" => NULL, NULL => 3 ), + array( 12, "name", 'age', '45' ), +); + +$counter = 0; + +foreach ( $mixed_array as $sub_array ) { + echo "\n-- Iteration $counter --\n"; + $counter++; + + var_dump ( extract($sub_array)); /* Single Argument */ + + /* variations of two arguments */ + var_dump ( extract($sub_array, EXTR_OVERWRITE)); + var_dump ( extract($sub_array, EXTR_SKIP)); + var_dump ( extract($sub_array, EXTR_IF_EXISTS)); + + /* variations of three arguments with use of various extract types*/ + var_dump ( extract($sub_array, EXTR_PREFIX_INVALID, "ssd")); + var_dump ( extract($sub_array, EXTR_PREFIX_SAME, "sss")); + var_dump ( extract($sub_array, EXTR_PREFIX_ALL, "bb")); + var_dump ( extract($sub_array, EXTR_PREFIX_ALL, "")); // "_" taken as default prefix + var_dump ( extract($sub_array, EXTR_PREFIX_IF_EXISTS, "bb")); +} + +echo "Done\n"; +?> +--EXPECTF-- +-- Iteration 0 -- +int(0) +int(0) +int(0) +int(0) +int(5) +int(0) +int(5) +int(5) +int(0) + +-- Iteration 1 -- +int(4) +int(4) +int(0) +int(4) +int(12) +int(4) +int(11) +int(11) +int(4) + +-- Iteration 2 -- +int(0) +int(0) +int(0) +int(0) +int(4) +int(0) +int(4) +int(4) +int(0) +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/extract_variation5.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/extract_variation5.phpt diff -u /dev/null php-src/ext/standard/tests/array/extract_variation5.phpt:1.2 --- /dev/null Fri Aug 10 13:27:05 2007 +++ php-src/ext/standard/tests/array/extract_variation5.phpt Fri Aug 10 13:27:05 2007 @@ -0,0 +1,57 @@ +--TEST-- +Test extract() function (variation 5) +--FILE-- +<?php + +$mixed_array = array( + array( array("oNe", "tWo", 4), array(10, 20, 30, 40, 50), array() ), + array( "one" => 1, "one" => 2, "three" => 3, 3, 4, 3 => 33, 4 => 44, 5, 6, + 5.4 => 54, 5.7 => 57, "5.4" => 554, "5.7" => 557 ) +); + +$counter = 0; + +foreach ( $mixed_array as $sub_array ) { + echo "\n-- Iteration $counter --\n"; + $counter++; + + var_dump ( extract($sub_array)); /* Single Argument */ + + /* variations of two arguments */ + var_dump ( extract($sub_array, EXTR_OVERWRITE)); + var_dump ( extract($sub_array, EXTR_SKIP)); + var_dump ( extract($sub_array, EXTR_IF_EXISTS)); + + /* variations of three arguments with use of various extract types*/ + var_dump ( extract($sub_array, EXTR_PREFIX_INVALID, "ssd")); + var_dump ( extract($sub_array, EXTR_PREFIX_SAME, "sss")); + var_dump ( extract($sub_array, EXTR_PREFIX_ALL, "bb")); + var_dump ( extract($sub_array, EXTR_PREFIX_ALL, "")); // "_" taken as default prefix + var_dump ( extract($sub_array, EXTR_PREFIX_IF_EXISTS, "bb")); +} + +echo "Done\n"; +?> +--EXPECTF-- +-- Iteration 0 -- +int(0) +int(0) +int(0) +int(0) +int(3) +int(0) +int(3) +int(3) +int(0) + +-- Iteration 1 -- +int(2) +int(2) +int(0) +int(2) +int(8) +int(2) +int(8) +int(8) +int(2) +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/extract_variation6.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/extract_variation6.phpt diff -u /dev/null php-src/ext/standard/tests/array/extract_variation6.phpt:1.2 --- /dev/null Fri Aug 10 13:27:05 2007 +++ php-src/ext/standard/tests/array/extract_variation6.phpt Fri Aug 10 13:27:05 2007 @@ -0,0 +1,38 @@ +--TEST-- +Test extract() function (variation 6) +--FILE-- +<?php + +/* EXTR_REFS as second Argument */ +$a = array ('foo' => 'aaa'); +var_dump ( extract($a, EXTR_REFS)); +var_dump($foo); + +$b = $a; +$b['foo'] = 'bbb'; +var_dump ( extract($a, EXTR_REFS)); +var_dump($foo); +var_dump($a); + +echo "Done\n"; +?> +--EXPECTF-- +int(1) +string(3) "aaa" +int(1) +string(3) "bbb" +array(1) { + ["foo"]=> + &string(3) "bbb" +} +Done +--UEXPECTF-- +int(1) +unicode(3) "aaa" +int(1) +unicode(3) "bbb" +array(1) { + [u"foo"]=> + &unicode(3) "bbb" +} +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/extract_variation7.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/extract_variation7.phpt diff -u /dev/null php-src/ext/standard/tests/array/extract_variation7.phpt:1.2 --- /dev/null Fri Aug 10 13:27:05 2007 +++ php-src/ext/standard/tests/array/extract_variation7.phpt Fri Aug 10 13:27:05 2007 @@ -0,0 +1,23 @@ +--TEST-- +Test extract() function (variation 7) +--FILE-- +<?php + +/* EXTR_PREFIX_ALL called twice with same prefix string */ +echo "\n*** Testing for EXTR_PREFIX_ALL called twice with same prefix string ***\n"; +$a = array( "1" => "one", "2" => "two", "3" => "three", "4" => "four", "5" => "five" ); +var_dump ( extract($a, EXTR_PREFIX_ALL, "same")); + +$b = array( "f" => "fff", "1" => "one", 4 => 6, "" => "blank", 2.4 => "float", "F" => "FFF", + "blank" => "", 3.7 => 3.7, 5.4 => 7, 6 => 8.6, '5' => "Five", "4name" => "jonny", "a" => NULL, NULL => 3 ); +var_dump ( extract($b, EXTR_PREFIX_ALL, "same")); +var_dump ( extract($b, EXTR_PREFIX_ALL, "diff")); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing for EXTR_PREFIX_ALL called twice with same prefix string *** +int(5) +int(11) +int(11) +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/extract_variation8.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/extract_variation8.phpt diff -u /dev/null php-src/ext/standard/tests/array/extract_variation8.phpt:1.2 --- /dev/null Fri Aug 10 13:27:05 2007 +++ php-src/ext/standard/tests/array/extract_variation8.phpt Fri Aug 10 13:27:05 2007 @@ -0,0 +1,26 @@ +--TEST-- +Test extract() function (variation 8) +--FILE-- +<?php + +/* To show variables with numerical prefixes cannot be extracted */ +$var["i"] = 1; +$var["j"] = 2; +$var["k"] = 3; +echo "\n*** Testing for Numerical prefixes ***\n"; +var_dump(extract($var)); + +$var1["m"] = 1; +$var1[2] = 2; +$var1[] = 3; +var_dump ( extract($var1)); + +echo "\nDone"; +?> + +--EXPECTF-- +*** Testing for Numerical prefixes *** +int(3) +int(1) + +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/extract_variation9.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/extract_variation9.phpt diff -u /dev/null php-src/ext/standard/tests/array/extract_variation9.phpt:1.2 --- /dev/null Fri Aug 10 13:27:05 2007 +++ php-src/ext/standard/tests/array/extract_variation9.phpt Fri Aug 10 13:27:05 2007 @@ -0,0 +1,20 @@ +--TEST-- +Test extract() function (variation 9) +--FILE-- +<?php +/* Using Class and objects */ +echo "\n*** Testing for object ***\n"; +class classA +{ + public $v; +} + +$A = new classA(); +var_dump ( extract(get_object_vars($A),EXTR_REFS)); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing for object *** +int(1) +Done
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php