From: Raghubansh Kumar Date: Mon, 5 Nov 2007 13:50:33 +0000 (+0000) Subject: New testcases for array_intersect_assoc() function X-Git-Tag: RELEASE_2_0_0a1~1465 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7374d094b83663832814b3ca39b134b3d4d12c6a;p=php New testcases for array_intersect_assoc() function --- diff --git a/ext/standard/tests/array/array_intersect_assoc_basic.phpt b/ext/standard/tests/array/array_intersect_assoc_basic.phpt new file mode 100644 index 0000000000..1c04b997cf --- /dev/null +++ b/ext/standard/tests/array/array_intersect_assoc_basic.phpt @@ -0,0 +1,96 @@ +--TEST-- +Test array_intersect_assoc() function : basic functionality +--FILE-- + 1, "two" => 2); + +// default key array for both $arr1 and $arr2 argument +var_dump( array_intersect_assoc($arr_default_keys, $arr_default_keys) ); + +// default key array for $arr1 and associative array for $arr2 argument +var_dump( array_intersect_assoc($arr_default_keys, $arr_associative) ); + +// associative array for $arr1 and default key array for $arr2 +var_dump( array_intersect_assoc($arr_associative, $arr_default_keys) ); + +// associative array for both $arr1 and $arr2 argument +var_dump( array_intersect_assoc($arr_associative, $arr_associative) ); + +// more arrays to be intersected +$arr3 = array(2, 3, 4); +var_dump( array_intersect_assoc($arr_default_keys, $arr_associative, $arr3) ); +var_dump( array_intersect_assoc($arr_associative, $arr_default_keys, $arr3, $arr_associative) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_intersect_assoc() : basic functionality *** +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + string(5) "hello" + [3]=> + string(5) "world" +} +array(0) { +} +array(0) { +} +array(2) { + ["one"]=> + int(1) + ["two"]=> + int(2) +} +array(0) { +} +array(0) { +} +Done +--UEXPECTF-- +*** Testing array_intersect_assoc() : basic functionality *** +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + unicode(5) "hello" + [3]=> + unicode(5) "world" +} +array(0) { +} +array(0) { +} +array(2) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) +} +array(0) { +} +array(0) { +} +Done diff --git a/ext/standard/tests/array/array_intersect_assoc_error.phpt b/ext/standard/tests/array/array_intersect_assoc_error.phpt new file mode 100644 index 0000000000..df9285060d --- /dev/null +++ b/ext/standard/tests/array/array_intersect_assoc_error.phpt @@ -0,0 +1,50 @@ +--TEST-- +Test array_intersect_assoc() function : error conditions(Bug#43197) +--FILE-- + +--EXPECTF-- +*** Testing array_intersect_assoc() : error conditions *** + +-- Testing array_intersect_assoc() function with Zero arguments -- + +Warning: array_intersect_assoc(): at least 2 parameters are required, 0 given in %s on line %d +NULL + +-- Testing array_intersect_assoc() function with less than expected no. of arguments -- + +Warning: array_intersect_assoc(): at least 2 parameters are required, 1 given in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing array_intersect_assoc() : error conditions *** + +-- Testing array_intersect_assoc() function with Zero arguments -- + +Warning: array_intersect_assoc(): at least 2 parameters are required, 0 given in %s on line %d +NULL + +-- Testing array_intersect_assoc() function with less than expected no. of arguments -- + +Warning: array_intersect_assoc(): at least 2 parameters are required, 1 given in %s on line %d +NULL +Done + diff --git a/ext/standard/tests/array/array_intersect_assoc_variation1.phpt b/ext/standard/tests/array/array_intersect_assoc_variation1.phpt new file mode 100644 index 0000000000..bafd720725 --- /dev/null +++ b/ext/standard/tests/array/array_intersect_assoc_variation1.phpt @@ -0,0 +1,453 @@ +--TEST-- +Test array_intersect_assoc() function : usage variations - unexpected values for 'arr1' argument(Bug#43196) +--FILE-- + 1, "two" => 2); + +// get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "Class A object"; + } +} + +// heredoc string +$heredoc = << +--EXPECTF-- +*** Testing array_intersect() : Passing non-array values to $arr1 argument *** + +-- Iterator 1 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 2 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 3 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 4 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 5 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 6 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 7 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 8 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 9 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 10 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 11 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 12 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 13 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 14 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 15 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 16 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 17 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 18 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 19 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 20 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 21 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 22 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 23 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 24 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing array_intersect() : Passing non-array values to $arr1 argument *** + +-- Iterator 1 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 2 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 3 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 4 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 5 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 6 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 7 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 8 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 9 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 10 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 11 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 12 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 13 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 14 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 15 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 16 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 17 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 18 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 19 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 20 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 21 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 22 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 23 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 24 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL +Done +--UEXPECTF-- diff --git a/ext/standard/tests/array/array_intersect_assoc_variation10.phpt b/ext/standard/tests/array/array_intersect_assoc_variation10.phpt new file mode 100644 index 0000000000..35e2c1e4df --- /dev/null +++ b/ext/standard/tests/array/array_intersect_assoc_variation10.phpt @@ -0,0 +1,75 @@ +--TEST-- +Test array_intersect_assoc() function : usage variations - binary safe checking +--FILE-- + +--EXPECTF-- +*** Testing array_intersect_assoc() : binary safe checking *** +array(2) { + [0]=> + string(5) "hello" + [1]=> + string(5) "world" +} +array(2) { + [0]=> + string(5) "hello" + [1]=> + string(5) "world" +} +array(2) { + [0]=> + string(5) "hello" + [1]=> + string(5) "world" +} +Done +--UEXPECTF-- +*** Testing array_intersect_assoc() : binary safe checking *** +array(2) { + [0]=> + string(5) "hello" + [1]=> + string(5) "world" +} +array(2) { + [0]=> + unicode(5) "hello" + [1]=> + unicode(5) "world" +} +array(2) { + [0]=> + string(5) "hello" + [1]=> + string(5) "world" +} +Done diff --git a/ext/standard/tests/array/array_intersect_assoc_variation2.phpt b/ext/standard/tests/array/array_intersect_assoc_variation2.phpt new file mode 100644 index 0000000000..9cc0adb90c --- /dev/null +++ b/ext/standard/tests/array/array_intersect_assoc_variation2.phpt @@ -0,0 +1,454 @@ +--TEST-- +Test array_intersect_assoc() function : usage variations - unexpected values for 'arr2' argument(Bug#43196) +--FILE-- + 1, "two" => 2); + +// get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "Class A object"; + } +} + +// heredoc string +$heredoc = << +--EXPECTF-- +*** Testing array_intersect() : Passing non-array values to $arr1 argument *** + +-- Iterator 1 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 2 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 3 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 4 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 5 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 6 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 7 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 8 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 9 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 10 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 11 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 12 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 13 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 14 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 15 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 16 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 17 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 18 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 19 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 20 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 21 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 22 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 23 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 24 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing array_intersect() : Passing non-array values to $arr1 argument *** + +-- Iterator 1 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 2 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 3 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 4 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 5 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 6 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 7 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 8 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 9 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 10 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 11 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 12 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 13 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 14 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 15 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 16 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 17 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 18 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 19 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 20 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 21 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 22 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 23 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +-- Iterator 24 -- +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #1 is not an array in %s on line %d +NULL +Done +--UEXPECTF-- diff --git a/ext/standard/tests/array/array_intersect_assoc_variation3.phpt b/ext/standard/tests/array/array_intersect_assoc_variation3.phpt new file mode 100644 index 0000000000..3d545372fb --- /dev/null +++ b/ext/standard/tests/array/array_intersect_assoc_variation3.phpt @@ -0,0 +1,387 @@ +--TEST-- +Test array_intersect_assoc() function : usage variations - different arrays for 'arr1' argument +--FILE-- +22 +'single quoted string' +"double quoted string" +2222 != 1111.\t 0000 = 0000\n +EOT; + +// arrays to be passed to $arr1 argument +$arrays = array ( +/*1*/ array(1, 2), // with default keys and numeric values + array(1.1, 2.2), // with default keys & float values + array(false,true), // with default keys and boolean values + array(), // empty array +/*5*/ array(NULL), // with NULL + array("a\v\f","aaaa\r","b","b\tbbb","c","\[\]\!\@\#\$\%\^\&\*\(\)\{\}"), // with double quoted strings + array('a\v\f','aaaa\r','b','b\tbbb','c','\[\]\!\@\#\$\%\^\&\*\(\)\{\}'), // with single quoted strings + array("h1" => $blank_line, "h2" => $multiline_string, "h3" => $diff_whitespaces, $numeric_string), // with heredocs + + // associative arrays +/*9*/ array(1 => "one", 2 => "two", 3 => "three"), // explicit numeric keys, string values + array("one" => 1, "two" => 2, "three" => 3 ), // string keys & numeric values + array( 1 => 10, 2 => 20, 4 => 40, 3 => 30), // explicit numeric keys and numeric values + array( "one" => "ten", "two" => "twenty", "three" => "thirty"), // string key/value + array("one" => 1, 2 => "two", 4 => "four"), //mixed + + // associative array, containing null/empty/boolean values as key/value +/*14*/ array(NULL => "NULL", null => "null", "NULL" => NULL, "null" => null), + array(true => "true", false => "false", "false" => false, "true" => true), + array("" => "emptyd", '' => 'emptys', "emptyd" => "", 'emptys' => ''), + array(1 => '', 2 => "", 3 => NULL, 4 => null, 5 => false, 6 => true), + array('' => 1, "" => 2, NULL => 3, null => 4, false => 5, true => 6), + + // array with repetative keys +/*19*/ array("One" => 1, "two" => 2, "One" => 10, "two" => 20, "three" => 3) +); + + +// array to be passsed to $arr2 argument +$arr2 = array ( + 1, 1.1, 2.2, "hello", "one", NULL, 2, + 'world', true,5 => false, 1 => 'aaaa\r', "aaaa\r", + 'h3' => $diff_whitespaces, $numeric_string, + "one" => "ten", 4 => "four", "two" => 2, + '', null => "null", '' => 'emptys', "emptyd" => "", +); + +// loop through each sub-array within $arrrays to check the behavior of array_intersect_assoc() +$iterator = 1; +foreach($arrays as $arr1) { + echo "-- Iteration $iterator --\n"; + + // Calling array_intersect_assoc() with default arguments + var_dump( array_intersect_assoc($arr1, $arr2) ); + + // Calling array_intersect_assoc() with more arguments. + // additional argument passed is the same as $arr1 argument + var_dump( array_intersect_assoc($arr1, $arr2, $arr1) ); + $iterator++; +} + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_intersect_assoc() : Passing different types of arrays to $arr1 argument *** +-- Iteration 1 -- +array(1) { + [0]=> + int(1) +} +array(1) { + [0]=> + int(1) +} +-- Iteration 2 -- +array(0) { +} +array(0) { +} +-- Iteration 3 -- +array(0) { +} +array(0) { +} +-- Iteration 4 -- +array(0) { +} +array(0) { +} +-- Iteration 5 -- +array(0) { +} +array(0) { +} +-- Iteration 6 -- +array(0) { +} +array(0) { +} +-- Iteration 7 -- +array(1) { + [1]=> + string(6) "aaaa\r" +} +array(1) { + [1]=> + string(6) "aaaa\r" +} +-- Iteration 8 -- +array(1) { + ["h3"]=> + string(88) "hello + world +1111 != 2222 +heredoc +double quoted string. with different white spaces" +} +array(1) { + ["h3"]=> + string(88) "hello + world +1111 != 2222 +heredoc +double quoted string. with different white spaces" +} +-- Iteration 9 -- +array(0) { +} +array(0) { +} +-- Iteration 10 -- +array(1) { + ["two"]=> + int(2) +} +array(1) { + ["two"]=> + int(2) +} +-- Iteration 11 -- +array(0) { +} +array(0) { +} +-- Iteration 12 -- +array(1) { + ["one"]=> + string(3) "ten" +} +array(1) { + ["one"]=> + string(3) "ten" +} +-- Iteration 13 -- +array(1) { + [4]=> + string(4) "four" +} +array(1) { + [4]=> + string(4) "four" +} +-- Iteration 14 -- +array(0) { +} +array(0) { +} +-- Iteration 15 -- +array(0) { +} +array(0) { +} +-- Iteration 16 -- +array(2) { + [""]=> + string(6) "emptys" + ["emptyd"]=> + string(0) "" +} +array(2) { + [""]=> + string(6) "emptys" + ["emptyd"]=> + string(0) "" +} +-- Iteration 17 -- +array(1) { + [5]=> + bool(false) +} +array(1) { + [5]=> + bool(false) +} +-- Iteration 18 -- +array(0) { +} +array(0) { +} +-- Iteration 19 -- +array(0) { +} +array(0) { +} +Done +--UEXPECTF-- +*** Testing array_intersect_assoc() : Passing different types of arrays to $arr1 argument *** +-- Iteration 1 -- +array(1) { + [0]=> + int(1) +} +array(1) { + [0]=> + int(1) +} +-- Iteration 2 -- +array(0) { +} +array(0) { +} +-- Iteration 3 -- +array(0) { +} +array(0) { +} +-- Iteration 4 -- +array(0) { +} +array(0) { +} +-- Iteration 5 -- +array(0) { +} +array(0) { +} +-- Iteration 6 -- +array(0) { +} +array(0) { +} +-- Iteration 7 -- +array(1) { + [1]=> + unicode(6) "aaaa\r" +} +array(1) { + [1]=> + unicode(6) "aaaa\r" +} +-- Iteration 8 -- +array(1) { + [u"h3"]=> + unicode(88) "hello + world +1111 != 2222 +heredoc +double quoted string. with different white spaces" +} +array(1) { + [u"h3"]=> + unicode(88) "hello + world +1111 != 2222 +heredoc +double quoted string. with different white spaces" +} +-- Iteration 9 -- +array(0) { +} +array(0) { +} +-- Iteration 10 -- +array(1) { + [u"two"]=> + int(2) +} +array(1) { + [u"two"]=> + int(2) +} +-- Iteration 11 -- +array(0) { +} +array(0) { +} +-- Iteration 12 -- +array(1) { + [u"one"]=> + unicode(3) "ten" +} +array(1) { + [u"one"]=> + unicode(3) "ten" +} +-- Iteration 13 -- +array(1) { + [4]=> + unicode(4) "four" +} +array(1) { + [4]=> + unicode(4) "four" +} +-- Iteration 14 -- +array(0) { +} +array(0) { +} +-- Iteration 15 -- +array(0) { +} +array(0) { +} +-- Iteration 16 -- +array(2) { + [u""]=> + unicode(6) "emptys" + [u"emptyd"]=> + unicode(0) "" +} +array(2) { + [u""]=> + unicode(6) "emptys" + [u"emptyd"]=> + unicode(0) "" +} +-- Iteration 17 -- +array(1) { + [5]=> + bool(false) +} +array(1) { + [5]=> + bool(false) +} +-- Iteration 18 -- +array(0) { +} +array(0) { +} +-- Iteration 19 -- +array(0) { +} +array(0) { +} +Done diff --git a/ext/standard/tests/array/array_intersect_assoc_variation4.phpt b/ext/standard/tests/array/array_intersect_assoc_variation4.phpt new file mode 100644 index 0000000000..81c24006fb --- /dev/null +++ b/ext/standard/tests/array/array_intersect_assoc_variation4.phpt @@ -0,0 +1,410 @@ +--TEST-- +Test array_intersect_assoc() function : usage variations - different arrays for 'arr2' argument +--FILE-- +22 +'single quoted string' +"double quoted string" +2222 != 1111.\t 0000 = 0000\n +EOT; + +// array to be passsed to $arr1 argument +$arr1 = array ( + 1, 1.1, 1.3, 1 => true, "hello", "one", NULL, 2, + 'world', true, false, 3 => "b\tbbb", "aaaa\r", + $numeric_string, "h3" => $diff_whitespaces, "true" => true, + "one" => "ten", 4 => "four", "two" => 2, 6 => "six", + '', null => "null", '' => 'emptys' +); + +// arrays to be passed to $arr2 argument +$arrays = array ( +/*1*/ array(1, 2), // array with default keys and numeric values + array(1.1, 1.2, 1.3), // array with default keys & float values + array(false,true), // array with default keys and boolean values + array(), // empty array +/*5*/ array(NULL), // array with NULL + array("a\v\f","aaaa\r","b","b\tbbb","c","\[\]\!\@\#\$\%\^\&\*\(\)\{\}"), // array with double quoted strings + array('a\v\f','aaaa\r','b','b\tbbb','c','\[\]\!\@\#\$\%\^\&\*\(\)\{\}'), // array with single quoted strings + array($blank_line, "h2" => $multiline_string, "h3" => $diff_whitespaces, $numeric_string), // array with heredocs + + // associative arrays +/*9*/ array(1 => "one", 2 => "two", 6 => "six"), // explicit numeric keys, string values + array("one" => 1, "two" => 2, "three" => 3 ), // string keys & numeric values + array( 1 => 10, 2 => 20, 4 => 40, 3 => 30), // explicit numeric keys and numeric values + array( "one" => "ten", "two" => "twenty", "three" => "thirty"), // string key/value + array("one" => 1, 2 => "two", 4 => "four"), //mixed + + // associative array, containing null/empty/boolean values as key/value +/*14*/ array(NULL => "NULL", null => "null", "NULL" => NULL, "null" => null), + array(true => "true", false => "false", "false" => false, "true" => true), + array("" => "emptyd", '' => 'emptys', "emptyd" => "", 'emptys' => ''), + array(1 => '', 2 => "", 3 => NULL, 4 => null, 5 => false, 6 => true), + array('' => 1, "" => 2, NULL => 3, null => 4, false => 5, true => 6), + + // array with repetative keys +/*19*/ array("One" => 1, "two" => 2, "One" => 10, "two" => 20, "three" => 3) +); + +// loop through each sub-array within $arrrays to check the behavior of array_intersect_assoc() +$iterator = 1; +foreach($arrays as $arr2) { + echo "-- Iteration $iterator --\n"; + + // Calling array_intersect_assoc() with default arguments + var_dump( array_intersect_assoc($arr1, $arr2) ); + + // Calling array_intersect_assoc() with more arguments + // additional argument passed is the same as $arr1 argument + var_dump( array_intersect_assoc($arr1, $arr2, $arr1) ); + $iterator++; +} + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_intersect_assoc() : Passing different types of arrays to $arr2 argument *** +-- Iteration 1 -- +array(1) { + [0]=> + int(1) +} +array(1) { + [0]=> + int(1) +} +-- Iteration 2 -- +array(1) { + [2]=> + float(1.3) +} +array(1) { + [2]=> + float(1.3) +} +-- Iteration 3 -- +array(1) { + [1]=> + bool(true) +} +array(1) { + [1]=> + bool(true) +} +-- Iteration 4 -- +array(0) { +} +array(0) { +} +-- Iteration 5 -- +array(0) { +} +array(0) { +} +-- Iteration 6 -- +array(1) { + [3]=> + string(5) "b bbb" +} +array(1) { + [3]=> + string(5) "b bbb" +} +-- Iteration 7 -- +array(0) { +} +array(0) { +} +-- Iteration 8 -- +array(1) { + ["h3"]=> + string(88) "hello + world +1111 != 2222 +heredoc +double quoted string. with different white spaces" +} +array(1) { + ["h3"]=> + string(88) "hello + world +1111 != 2222 +heredoc +double quoted string. with different white spaces" +} +-- Iteration 9 -- +array(1) { + [6]=> + string(3) "six" +} +array(1) { + [6]=> + string(3) "six" +} +-- Iteration 10 -- +array(1) { + ["two"]=> + int(2) +} +array(1) { + ["two"]=> + int(2) +} +-- Iteration 11 -- +array(0) { +} +array(0) { +} +-- Iteration 12 -- +array(1) { + ["one"]=> + string(3) "ten" +} +array(1) { + ["one"]=> + string(3) "ten" +} +-- Iteration 13 -- +array(1) { + [4]=> + string(4) "four" +} +array(1) { + [4]=> + string(4) "four" +} +-- Iteration 14 -- +array(0) { +} +array(0) { +} +-- Iteration 15 -- +array(1) { + ["true"]=> + bool(true) +} +array(1) { + ["true"]=> + bool(true) +} +-- Iteration 16 -- +array(1) { + [""]=> + string(6) "emptys" +} +array(1) { + [""]=> + string(6) "emptys" +} +-- Iteration 17 -- +array(1) { + [5]=> + NULL +} +array(1) { + [5]=> + NULL +} +-- Iteration 18 -- +array(0) { +} +array(0) { +} +-- Iteration 19 -- +array(0) { +} +array(0) { +} +Done +--UEXPECTF-- +*** Testing array_intersect_assoc() : Passing different types of arrays to $arr2 argument *** +-- Iteration 1 -- +array(1) { + [0]=> + int(1) +} +array(1) { + [0]=> + int(1) +} +-- Iteration 2 -- +array(1) { + [2]=> + float(1.3) +} +array(1) { + [2]=> + float(1.3) +} +-- Iteration 3 -- +array(1) { + [1]=> + bool(true) +} +array(1) { + [1]=> + bool(true) +} +-- Iteration 4 -- +array(0) { +} +array(0) { +} +-- Iteration 5 -- +array(0) { +} +array(0) { +} +-- Iteration 6 -- +array(1) { + [3]=> + unicode(5) "b bbb" +} +array(1) { + [3]=> + unicode(5) "b bbb" +} +-- Iteration 7 -- +array(0) { +} +array(0) { +} +-- Iteration 8 -- +array(1) { + [u"h3"]=> + unicode(88) "hello + world +1111 != 2222 +heredoc +double quoted string. with different white spaces" +} +array(1) { + [u"h3"]=> + unicode(88) "hello + world +1111 != 2222 +heredoc +double quoted string. with different white spaces" +} +-- Iteration 9 -- +array(1) { + [6]=> + unicode(3) "six" +} +array(1) { + [6]=> + unicode(3) "six" +} +-- Iteration 10 -- +array(1) { + [u"two"]=> + int(2) +} +array(1) { + [u"two"]=> + int(2) +} +-- Iteration 11 -- +array(0) { +} +array(0) { +} +-- Iteration 12 -- +array(1) { + [u"one"]=> + unicode(3) "ten" +} +array(1) { + [u"one"]=> + unicode(3) "ten" +} +-- Iteration 13 -- +array(1) { + [4]=> + unicode(4) "four" +} +array(1) { + [4]=> + unicode(4) "four" +} +-- Iteration 14 -- +array(0) { +} +array(0) { +} +-- Iteration 15 -- +array(1) { + [u"true"]=> + bool(true) +} +array(1) { + [u"true"]=> + bool(true) +} +-- Iteration 16 -- +array(1) { + [u""]=> + unicode(6) "emptys" +} +array(1) { + [u""]=> + unicode(6) "emptys" +} +-- Iteration 17 -- +array(1) { + [5]=> + NULL +} +array(1) { + [5]=> + NULL +} +-- Iteration 18 -- +array(0) { +} +array(0) { +} +-- Iteration 19 -- +array(0) { +} +array(0) { +} +Done diff --git a/ext/standard/tests/array/array_intersect_assoc_variation5.phpt b/ext/standard/tests/array/array_intersect_assoc_variation5.phpt new file mode 100644 index 0000000000..0cd97e9ece --- /dev/null +++ b/ext/standard/tests/array/array_intersect_assoc_variation5.phpt @@ -0,0 +1,299 @@ +--TEST-- +Test array_intersect_assoc() function : usage variations - assoc array with diff keys for 'arr1' argument +--FILE-- + "0"), + array(1 => "1"), + array(1 => "1", 2 => "2", 3 => "3", 4 => "4"), + + // arrays with float keys +/*5*/ array(2.3333 => "float"), + array(1.2 => "f1", 3.33 => "f2", + 4.89999922839999 => "f3", + 33333333.333333 => "f4"), + + // arrays with string keys +/*7*/ array('\tHello' => 111, 're\td' => "color", + '\v\fworld' => 2.2, 'pen\n' => 33), + array("\tHello" => 111, "re\td" => "color", + "\v\fworld" => 2.2, "pen\n" => 33), + array("hello", $heredoc => "string"), // heredoc + + // array with object, unset variable and resource variable +/*10*/ array(new classA() => 11, @$unset_var => "hello", $fp => 'resource'), + + // array with mixed keys +/*11*/ array('hello' => 1, new classA() => 2, "fruit" => 2.2, + $fp => 'resource', 133 => "int", 444.432 => "float", + @$unset_var => "unset", $heredoc => "heredoc") +); + +// array to be passsed to $arr2 argument +$arr2 = array(0 => 0, 2 => "float", 4 => "f3", 33333333 => "f4", + "\tHello" => 111, 2.2, 'color', "Hello world" => "string", + "pen\n" => 33, new classA() => 11, 133 => "int"); + +// loop through each sub-array within $arrrays to check the behavior of array_intersect_assoc() +$iterator = 1; +foreach($arrays as $arr1) { + echo "-- Iteration $iterator --\n"; + + // Calling array_intersect_assoc() with default arguments + var_dump( array_intersect_assoc($arr1, $arr2) ); + + // Calling array_intersect_assoc() with more arguments. + // additional argument passed is the same as $arr1 argument + var_dump( array_intersect_assoc($arr1, $arr2, $arr1) ); + $iterator++; +} + +// close the file resource used +fclose($fp); + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_intersect_assoc() : assoc array with diff keys to $arr1 argument *** + +Warning: Illegal offset type in %s on line %d + +Warning: Illegal offset type in %s on line %d + +Warning: Illegal offset type in %s on line %d + +Warning: Illegal offset type in %s on line %d + +Warning: Illegal offset type in %s on line %d +-- Iteration 1 -- +array(0) { +} +array(0) { +} +-- Iteration 2 -- +array(1) { + [0]=> + string(1) "0" +} +array(1) { + [0]=> + string(1) "0" +} +-- Iteration 3 -- +array(0) { +} +array(0) { +} +-- Iteration 4 -- +array(0) { +} +array(0) { +} +-- Iteration 5 -- +array(1) { + [2]=> + string(5) "float" +} +array(1) { + [2]=> + string(5) "float" +} +-- Iteration 6 -- +array(2) { + [4]=> + string(2) "f3" + [33333333]=> + string(2) "f4" +} +array(2) { + [4]=> + string(2) "f3" + [33333333]=> + string(2) "f4" +} +-- Iteration 7 -- +array(0) { +} +array(0) { +} +-- Iteration 8 -- +array(2) { + [" Hello"]=> + int(111) + ["pen +"]=> + int(33) +} +array(2) { + [" Hello"]=> + int(111) + ["pen +"]=> + int(33) +} +-- Iteration 9 -- +array(1) { + ["Hello world"]=> + string(6) "string" +} +array(1) { + ["Hello world"]=> + string(6) "string" +} +-- Iteration 10 -- +array(0) { +} +array(0) { +} +-- Iteration 11 -- +array(1) { + [133]=> + string(3) "int" +} +array(1) { + [133]=> + string(3) "int" +} +Done +--UEXPECTF-- +*** Testing array_intersect_assoc() : assoc array with diff keys to $arr1 argument *** + +Warning: Illegal offset type in %s on line %d + +Warning: Illegal offset type in %s on line %d + +Warning: Illegal offset type in %s on line %d + +Warning: Illegal offset type in %s on line %d + +Warning: Illegal offset type in %s on line %d +-- Iteration 1 -- +array(0) { +} +array(0) { +} +-- Iteration 2 -- +array(1) { + [0]=> + unicode(1) "0" +} +array(1) { + [0]=> + unicode(1) "0" +} +-- Iteration 3 -- +array(0) { +} +array(0) { +} +-- Iteration 4 -- +array(0) { +} +array(0) { +} +-- Iteration 5 -- +array(1) { + [2]=> + unicode(5) "float" +} +array(1) { + [2]=> + unicode(5) "float" +} +-- Iteration 6 -- +array(2) { + [4]=> + unicode(2) "f3" + [33333333]=> + unicode(2) "f4" +} +array(2) { + [4]=> + unicode(2) "f3" + [33333333]=> + unicode(2) "f4" +} +-- Iteration 7 -- +array(0) { +} +array(0) { +} +-- Iteration 8 -- +array(2) { + [u" Hello"]=> + int(111) + [u"pen +"]=> + int(33) +} +array(2) { + [u" Hello"]=> + int(111) + [u"pen +"]=> + int(33) +} +-- Iteration 9 -- +array(1) { + [u"Hello world"]=> + unicode(6) "string" +} +array(1) { + [u"Hello world"]=> + unicode(6) "string" +} +-- Iteration 10 -- +array(0) { +} +array(0) { +} +-- Iteration 11 -- +array(1) { + [133]=> + unicode(3) "int" +} +array(1) { + [133]=> + unicode(3) "int" +} +Done diff --git a/ext/standard/tests/array/array_intersect_assoc_variation6.phpt b/ext/standard/tests/array/array_intersect_assoc_variation6.phpt new file mode 100644 index 0000000000..506a824080 --- /dev/null +++ b/ext/standard/tests/array/array_intersect_assoc_variation6.phpt @@ -0,0 +1,299 @@ +--TEST-- +Test array_intersect_assoc() function : usage variations - assoc array with diff keys for 'arr2' argument +--FILE-- + "0"), + array(1 => "1"), + array(1 => "1", 2 => "2", 3 => "3", 4 => "4"), + + // arrays with float keys +/*5*/ array(2.3333 => "float"), + array(1.2 => "f1", 3.33 => "f2", + 4.89999922839999 => "f3", + 33333333.333333 => "f4"), + + // arrays with string keys +/*7*/ array('\tHello' => 111, 're\td' => "color", + '\v\fworld' => 2.2, 'pen\n' => 33), + array("\tHello" => 111, "re\td" => "color", + "\v\fworld" => 2.2, "pen\n" => 33), + array("hello", $heredoc => "string"), // heredoc + + // array with object, unset variable and resource variable +/*10*/ array(new classA() => 11, @$unset_var => "hello", $fp => 'resource'), + + // array with mixed keys +/*11*/ array('hello' => 1, new classA() => 2, "fruit" => 2.2, + $fp => 'resource', 133 => "int", 444.432 => "float", + @$unset_var => "unset", $heredoc => "heredoc") +); + +// array to be passsed to $arr1 argument +$arr1 = array(0 => 0, 2 => "float", 4 => "f3", 33333333 => "f4", + "\tHello" => 111, 2.2, 'color', "Hello world" => "string", + "pen\n" => 33, new classA() => 11, 133 => "int"); + +// loop through each sub-array within $arrrays to check the behavior of array_intersect_assoc() +$iterator = 1; +foreach($arrays as $arr2) { + echo "-- Iteration $iterator --\n"; + + // Calling array_intersect_assoc() with default arguments + var_dump( array_intersect_assoc($arr1, $arr2) ); + + // Calling array_intersect_assoc() with more arguments. + // additional argument passed is the same as $arr1 argument + var_dump( array_intersect_assoc($arr1, $arr2, $arr1) ); + $iterator++; +} + +// close the file resource used +fclose($fp); + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_intersect_assoc() : assoc array with diff keys to $arr2 argument *** + +Warning: Illegal offset type in %s on line %d + +Warning: Illegal offset type in %s on line %d + +Warning: Illegal offset type in %s on line %d + +Warning: Illegal offset type in %s on line %d + +Warning: Illegal offset type in %s on line %d +-- Iteration 1 -- +array(0) { +} +array(0) { +} +-- Iteration 2 -- +array(1) { + [0]=> + int(0) +} +array(1) { + [0]=> + int(0) +} +-- Iteration 3 -- +array(0) { +} +array(0) { +} +-- Iteration 4 -- +array(0) { +} +array(0) { +} +-- Iteration 5 -- +array(1) { + [2]=> + string(5) "float" +} +array(1) { + [2]=> + string(5) "float" +} +-- Iteration 6 -- +array(2) { + [4]=> + string(2) "f3" + [33333333]=> + string(2) "f4" +} +array(2) { + [4]=> + string(2) "f3" + [33333333]=> + string(2) "f4" +} +-- Iteration 7 -- +array(0) { +} +array(0) { +} +-- Iteration 8 -- +array(2) { + [" Hello"]=> + int(111) + ["pen +"]=> + int(33) +} +array(2) { + [" Hello"]=> + int(111) + ["pen +"]=> + int(33) +} +-- Iteration 9 -- +array(1) { + ["Hello world"]=> + string(6) "string" +} +array(1) { + ["Hello world"]=> + string(6) "string" +} +-- Iteration 10 -- +array(0) { +} +array(0) { +} +-- Iteration 11 -- +array(1) { + [133]=> + string(3) "int" +} +array(1) { + [133]=> + string(3) "int" +} +Done +--UEXPECTF-- +*** Testing array_intersect_assoc() : assoc array with diff keys to $arr2 argument *** + +Warning: Illegal offset type in %s on line %d + +Warning: Illegal offset type in %s on line %d + +Warning: Illegal offset type in %s on line %d + +Warning: Illegal offset type in %s on line %d + +Warning: Illegal offset type in %s on line %d +-- Iteration 1 -- +array(0) { +} +array(0) { +} +-- Iteration 2 -- +array(1) { + [0]=> + int(0) +} +array(1) { + [0]=> + int(0) +} +-- Iteration 3 -- +array(0) { +} +array(0) { +} +-- Iteration 4 -- +array(0) { +} +array(0) { +} +-- Iteration 5 -- +array(1) { + [2]=> + unicode(5) "float" +} +array(1) { + [2]=> + unicode(5) "float" +} +-- Iteration 6 -- +array(2) { + [4]=> + unicode(2) "f3" + [33333333]=> + unicode(2) "f4" +} +array(2) { + [4]=> + unicode(2) "f3" + [33333333]=> + unicode(2) "f4" +} +-- Iteration 7 -- +array(0) { +} +array(0) { +} +-- Iteration 8 -- +array(2) { + [u" Hello"]=> + int(111) + [u"pen +"]=> + int(33) +} +array(2) { + [u" Hello"]=> + int(111) + [u"pen +"]=> + int(33) +} +-- Iteration 9 -- +array(1) { + [u"Hello world"]=> + unicode(6) "string" +} +array(1) { + [u"Hello world"]=> + unicode(6) "string" +} +-- Iteration 10 -- +array(0) { +} +array(0) { +} +-- Iteration 11 -- +array(1) { + [133]=> + unicode(3) "int" +} +array(1) { + [133]=> + unicode(3) "int" +} +Done diff --git a/ext/standard/tests/array/array_intersect_assoc_variation7.phpt b/ext/standard/tests/array/array_intersect_assoc_variation7.phpt new file mode 100644 index 0000000000..396e7ba151 --- /dev/null +++ b/ext/standard/tests/array/array_intersect_assoc_variation7.phpt @@ -0,0 +1,332 @@ +--TEST-- +Test array_intersect_assoc() function : usage variations - assoc array with diff values for 'arr1' argument +--FILE-- + 0), + array("1" => 1), + array("one" => 1, 'two' => 2, "three" => 3, 4 => 4), + + // arrays with float values +/*5*/ array("float" => 2.3333), + array("f1" => 1.2, 'f2' => 3.33, 3 => 4.89999922839999, 'f4' => 33333333.333), + + // arrays with string values +/*7*/ array(111 => "\tHello", "red" => "col\tor", 2 => "\v\fworld", 3.3 => "pen\n"), + array(111 => '\tHello', "red" => 'col\tor', 2 => '\v\fworld', 3.3 => 'pen\n'), + array(1 => "hello", "heredoc" => $heredoc), + + // array with object, unset variable and resource variable +/*10*/ array(11 => new classA(), "unset" => @$unset_var, "resource" => $fp), + + // array with mixed values +/*11*/ array(1 => 'hello', 2 => new classA(), 222 => "fruit", + 'resource' => $fp, "int" => 133, "float" => 444.432, + "unset" => @$unset_var, "heredoc" => $heredoc) +); + +// array to be passsed to $arr2 argument +$arr2 = array(0 => "0", 1, "two" => 2, "float" => 2.3333, "f1" => 1.2, + "f4" => 33333333.333, 111 => "\tHello", 3.3 => 'pen\n', '\v\fworld', + "heredoc" => "Hello world", 11 => new classA(), "resource" => $fp, + "int" => 133, 222 => "fruit"); + +// loop through each sub-array within $arrrays to check the behavior of array_intersect_assoc() +$iterator = 1; +foreach($arrays as $arr1) { + echo "-- Iteration $iterator --\n"; + + // Calling array_intersect_assoc() with default arguments + var_dump( array_intersect_assoc($arr1, $arr2) ); + + // Calling array_intersect_assoc() with more arguments. + // additional argument passed is the same as $arr1 argument + var_dump( array_intersect_assoc($arr1, $arr2, $arr1) ); + $iterator++; +} + +// close the file resource used +fclose($fp); + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_intersect_assoc() : assoc array with diff values to $arr1 argument *** +-- Iteration 1 -- +array(0) { +} +array(0) { +} +-- Iteration 2 -- +array(1) { + [0]=> + int(0) +} +array(1) { + [0]=> + int(0) +} +-- Iteration 3 -- +array(1) { + [1]=> + int(1) +} +array(1) { + [1]=> + int(1) +} +-- Iteration 4 -- +array(1) { + ["two"]=> + int(2) +} +array(1) { + ["two"]=> + int(2) +} +-- Iteration 5 -- +array(1) { + ["float"]=> + float(2.3333) +} +array(1) { + ["float"]=> + float(2.3333) +} +-- Iteration 6 -- +array(2) { + ["f1"]=> + float(1.2) + ["f4"]=> + float(33333333.333) +} +array(2) { + ["f1"]=> + float(1.2) + ["f4"]=> + float(33333333.333) +} +-- Iteration 7 -- +array(1) { + [111]=> + string(6) " Hello" +} +array(1) { + [111]=> + string(6) " Hello" +} +-- Iteration 8 -- +array(1) { + [3]=> + string(5) "pen\n" +} +array(1) { + [3]=> + string(5) "pen\n" +} +-- Iteration 9 -- +array(1) { + ["heredoc"]=> + string(11) "Hello world" +} +array(1) { + ["heredoc"]=> + string(11) "Hello world" +} +-- Iteration 10 -- +array(2) { + [11]=> + object(classA)#%d (0) { + } + ["resource"]=> + resource(%d) of type (stream) +} +array(2) { + [11]=> + object(classA)#%d (0) { + } + ["resource"]=> + resource(%d) of type (stream) +} +-- Iteration 11 -- +array(4) { + [222]=> + string(5) "fruit" + ["resource"]=> + resource(%d) of type (stream) + ["int"]=> + int(133) + ["heredoc"]=> + string(11) "Hello world" +} +array(4) { + [222]=> + string(5) "fruit" + ["resource"]=> + resource(%d) of type (stream) + ["int"]=> + int(133) + ["heredoc"]=> + string(11) "Hello world" +} +Done +--UEXPECTF-- +*** Testing array_intersect_assoc() : assoc array with diff values to $arr1 argument *** +-- Iteration 1 -- +array(0) { +} +array(0) { +} +-- Iteration 2 -- +array(1) { + [0]=> + int(0) +} +array(1) { + [0]=> + int(0) +} +-- Iteration 3 -- +array(1) { + [1]=> + int(1) +} +array(1) { + [1]=> + int(1) +} +-- Iteration 4 -- +array(1) { + [u"two"]=> + int(2) +} +array(1) { + [u"two"]=> + int(2) +} +-- Iteration 5 -- +array(1) { + [u"float"]=> + float(2.3333) +} +array(1) { + [u"float"]=> + float(2.3333) +} +-- Iteration 6 -- +array(2) { + [u"f1"]=> + float(1.2) + [u"f4"]=> + float(33333333.333) +} +array(2) { + [u"f1"]=> + float(1.2) + [u"f4"]=> + float(33333333.333) +} +-- Iteration 7 -- +array(1) { + [111]=> + unicode(6) " Hello" +} +array(1) { + [111]=> + unicode(6) " Hello" +} +-- Iteration 8 -- +array(1) { + [3]=> + unicode(5) "pen\n" +} +array(1) { + [3]=> + unicode(5) "pen\n" +} +-- Iteration 9 -- +array(1) { + [u"heredoc"]=> + unicode(11) "Hello world" +} +array(1) { + [u"heredoc"]=> + unicode(11) "Hello world" +} +-- Iteration 10 -- +array(2) { + [11]=> + object(classA)#%d (0) { + } + [u"resource"]=> + resource(%d) of type (stream) +} +array(2) { + [11]=> + object(classA)#%d (0) { + } + [u"resource"]=> + resource(%d) of type (stream) +} +-- Iteration 11 -- +array(4) { + [222]=> + unicode(5) "fruit" + [u"resource"]=> + resource(%d) of type (stream) + [u"int"]=> + int(133) + [u"heredoc"]=> + unicode(11) "Hello world" +} +array(4) { + [222]=> + unicode(5) "fruit" + [u"resource"]=> + resource(%d) of type (stream) + [u"int"]=> + int(133) + [u"heredoc"]=> + unicode(11) "Hello world" +} +Done diff --git a/ext/standard/tests/array/array_intersect_assoc_variation8.phpt b/ext/standard/tests/array/array_intersect_assoc_variation8.phpt new file mode 100644 index 0000000000..e1443e8137 --- /dev/null +++ b/ext/standard/tests/array/array_intersect_assoc_variation8.phpt @@ -0,0 +1,332 @@ +--TEST-- +Test array_intersect_assoc() function : usage variations - assoc array with diff values for 'arr2' argument +--FILE-- + 0), + array("1" => 1), + array("one" => 1, 'two' => 2, "three" => 3, 4 => 4), + + // arrays with float values +/*5*/ array("float" => 2.3333), + array("f1" => 1.2, 'f2' => 3.33, 3 => 4.89999922839999, 'f4' => 33333333.333), + + // arrays with string values +/*7*/ array(111 => "\tHello", "red" => "col\tor", 2 => "\v\fworld", 3.3 => "pen\n"), + array(111 => '\tHello', "red" => 'col\tor', 2 => '\v\fworld', 3.3 => 'pen\n'), + array(1 => "hello", "heredoc" => $heredoc), + + // array with object, unset variable and resource variable +/*10*/ array(11 => new classA(), "unset" => @$unset_var, "resource" => $fp), + + // array with mixed values +/*11*/ array(1 => 'hello', 2 => new classA(), 222 => "fruit", + 'resource' => $fp, "int" => 133, "float" => 444.432, + "unset" => @$unset_var, "heredoc" => $heredoc) +); + +// array to be passsed to $arr1 argument +$arr1 = array(0 => "0", 1, "two" => 2, "float" => 2.3333, "f1" => 1.2, + "f4" => 33333333.333, 111 => "\tHello", 3.3 => 'pen\n', '\v\fworld', + "heredoc" => "Hello world", 11 => new classA(), "resource" => $fp, + "int" => 133, 222 => "fruit"); + +// loop through each sub-array within $arrrays to check the behavior of array_intersect_assoc() +$iterator = 1; +foreach($arrays as $arr2) { + echo "-- Iteration $iterator --\n"; + + // Calling array_intersect_assoc() with default arguments + var_dump( array_intersect_assoc($arr1, $arr2) ); + + // Calling array_intersect_assoc() with more arguments. + // additional argument passed is the same as $arr1 argument + var_dump( array_intersect_assoc($arr1, $arr2, $arr1) ); + $iterator++; +} + +// close the file resource used +fclose($fp); + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_intersect_assoc() : assoc array with diff values to $arr2 argument *** +-- Iteration 1 -- +array(0) { +} +array(0) { +} +-- Iteration 2 -- +array(1) { + [0]=> + string(1) "0" +} +array(1) { + [0]=> + string(1) "0" +} +-- Iteration 3 -- +array(1) { + [1]=> + int(1) +} +array(1) { + [1]=> + int(1) +} +-- Iteration 4 -- +array(1) { + ["two"]=> + int(2) +} +array(1) { + ["two"]=> + int(2) +} +-- Iteration 5 -- +array(1) { + ["float"]=> + float(2.3333) +} +array(1) { + ["float"]=> + float(2.3333) +} +-- Iteration 6 -- +array(2) { + ["f1"]=> + float(1.2) + ["f4"]=> + float(33333333.333) +} +array(2) { + ["f1"]=> + float(1.2) + ["f4"]=> + float(33333333.333) +} +-- Iteration 7 -- +array(1) { + [111]=> + string(6) " Hello" +} +array(1) { + [111]=> + string(6) " Hello" +} +-- Iteration 8 -- +array(1) { + [3]=> + string(5) "pen\n" +} +array(1) { + [3]=> + string(5) "pen\n" +} +-- Iteration 9 -- +array(1) { + ["heredoc"]=> + string(11) "Hello world" +} +array(1) { + ["heredoc"]=> + string(11) "Hello world" +} +-- Iteration 10 -- +array(2) { + [11]=> + object(classA)#%d (0) { + } + ["resource"]=> + resource(%d) of type (stream) +} +array(2) { + [11]=> + object(classA)#%d (0) { + } + ["resource"]=> + resource(%d) of type (stream) +} +-- Iteration 11 -- +array(4) { + ["heredoc"]=> + string(11) "Hello world" + ["resource"]=> + resource(%d) of type (stream) + ["int"]=> + int(133) + [222]=> + string(5) "fruit" +} +array(4) { + ["heredoc"]=> + string(11) "Hello world" + ["resource"]=> + resource(%d) of type (stream) + ["int"]=> + int(133) + [222]=> + string(5) "fruit" +} +Done +--UEXPECTF-- +*** Testing array_intersect_assoc() : assoc array with diff values to $arr2 argument *** +-- Iteration 1 -- +array(0) { +} +array(0) { +} +-- Iteration 2 -- +array(1) { + [0]=> + unicode(1) "0" +} +array(1) { + [0]=> + unicode(1) "0" +} +-- Iteration 3 -- +array(1) { + [1]=> + int(1) +} +array(1) { + [1]=> + int(1) +} +-- Iteration 4 -- +array(1) { + [u"two"]=> + int(2) +} +array(1) { + [u"two"]=> + int(2) +} +-- Iteration 5 -- +array(1) { + [u"float"]=> + float(2.3333) +} +array(1) { + [u"float"]=> + float(2.3333) +} +-- Iteration 6 -- +array(2) { + [u"f1"]=> + float(1.2) + [u"f4"]=> + float(33333333.333) +} +array(2) { + [u"f1"]=> + float(1.2) + [u"f4"]=> + float(33333333.333) +} +-- Iteration 7 -- +array(1) { + [111]=> + unicode(6) " Hello" +} +array(1) { + [111]=> + unicode(6) " Hello" +} +-- Iteration 8 -- +array(1) { + [3]=> + unicode(5) "pen\n" +} +array(1) { + [3]=> + unicode(5) "pen\n" +} +-- Iteration 9 -- +array(1) { + [u"heredoc"]=> + unicode(11) "Hello world" +} +array(1) { + [u"heredoc"]=> + unicode(11) "Hello world" +} +-- Iteration 10 -- +array(2) { + [11]=> + object(classA)#%d (0) { + } + [u"resource"]=> + resource(%d) of type (stream) +} +array(2) { + [11]=> + object(classA)#%d (0) { + } + [u"resource"]=> + resource(%d) of type (stream) +} +-- Iteration 11 -- +array(4) { + [u"heredoc"]=> + unicode(11) "Hello world" + [u"resource"]=> + resource(%d) of type (stream) + [u"int"]=> + int(133) + [222]=> + unicode(5) "fruit" +} +array(4) { + [u"heredoc"]=> + unicode(11) "Hello world" + [u"resource"]=> + resource(%d) of type (stream) + [u"int"]=> + int(133) + [222]=> + unicode(5) "fruit" +} +Done diff --git a/ext/standard/tests/array/array_intersect_assoc_variation9.phpt b/ext/standard/tests/array/array_intersect_assoc_variation9.phpt new file mode 100644 index 0000000000..7121863efc --- /dev/null +++ b/ext/standard/tests/array/array_intersect_assoc_variation9.phpt @@ -0,0 +1,245 @@ +--TEST-- +Test array_intersect_assoc() function : usage variations - two dimensional arrays for $arr1 and $arr2 arguments +--FILE-- + "one", 2 => "two", 3 => "three"), + array("ten" => 10, "twenty" => 20.00, "thirty" => 30) +); + +$arr2 = array ( + array(1, 2, 3, 4), + array(1 => "one", 2 => "two", 3 => "three") +); + +/* Passing the entire array as argument to $arr1 and $arr2 */ +// Calling array_intersect_assoc() with default arguments +echo "-- Passing the entire 2-D array to \$arr1 and \$arr2 --\n"; +echo "- With default arguments -\n"; +var_dump( array_intersect_assoc($arr1, $arr2) ); + +// Calling array_intersect_assoc() with more arguments +// additional argument passed is the same as $arr1 +echo "- With more arguments -\n"; +var_dump( array_intersect_assoc($arr1, $arr2, $arr1) ); + +/* Passing the sub-array as argument to $arr1 and $arr2 */ +// Calling array_intersect_assoc() with default arguments +echo "-- Passing the sub-array to \$arr1 and \$arr2 --\n"; +echo "- With default arguments -\n"; +var_dump( array_intersect_assoc($arr1[0], $arr2[0]) ); + +// Calling array_intersect_assoc() with more arguments +// additional argument passed is the same as $arr1 +echo "- With more arguments -\n"; +var_dump( array_intersect_assoc($arr1[0], $arr2[0], $arr1[0]) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_intersect_assoc() : passing two dimensional array to both $arr1 and $arr2 arguments *** +-- Passing the entire 2-D array to $arr1 and $arr2 -- +- With default arguments - + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d +array(2) { + [0]=> + array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + string(5) "hello" + [3]=> + string(5) "world" + } + [1]=> + array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + } +} +- With more arguments - + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d +array(2) { + [0]=> + array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + string(5) "hello" + [3]=> + string(5) "world" + } + [1]=> + array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + } +} +-- Passing the sub-array to $arr1 and $arr2 -- +- With default arguments - +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +- With more arguments - +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +Done +--UEXPECTF-- +*** Testing array_intersect_assoc() : passing two dimensional array to both $arr1 and $arr2 arguments *** +-- Passing the entire 2-D array to $arr1 and $arr2 -- +- With default arguments - + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d +array(2) { + [0]=> + array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + unicode(5) "hello" + [3]=> + unicode(5) "world" + } + [1]=> + array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + } +} +- With more arguments - + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d +array(2) { + [0]=> + array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + unicode(5) "hello" + [3]=> + unicode(5) "world" + } + [1]=> + array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + } +} +-- Passing the sub-array to $arr1 and $arr2 -- +- With default arguments - +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +- With more arguments - +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +Done