From: Raghubansh Kumar Date: Sat, 27 Oct 2007 12:13:05 +0000 (+0000) Subject: New testcases for array_intersect() function X-Git-Tag: RELEASE_2_0_0a1~1537 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0150849e42380cf862bab1591e6627842475d26f;p=php New testcases for array_intersect() function --- diff --git a/ext/standard/tests/array/array_intersect_basic.phpt b/ext/standard/tests/array/array_intersect_basic.phpt new file mode 100644 index 0000000000..3018b39e7a --- /dev/null +++ b/ext/standard/tests/array/array_intersect_basic.phpt @@ -0,0 +1,119 @@ +--TEST-- +Test array_intersect() function : basic functionality +--FILE-- + 1, "two" => 2); + +// default key array for both $arr1 and $arr2 argument +var_dump( array_intersect($arr_default_keys, $arr_default_keys) ); + +// default key array for $arr1 and associative array for $arr2 argument +var_dump( array_intersect($arr_default_keys, $arr_associative) ); + +// associative array for $arr1 and default key array for $arr2 +var_dump( array_intersect($arr_associative, $arr_default_keys) ); + +// associative array for both $arr1 and $arr2 argument +var_dump( array_intersect($arr_associative, $arr_associative) ); + +// more arrays to be intersected +$arr3 = array(2, 3, 4); +var_dump( array_intersect($arr_default_keys, $arr_associative, $arr3) ); +var_dump( array_intersect($arr_associative, $arr_default_keys, $arr3, $arr_associative) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_intersect() : basic functionality *** +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + string(5) "hello" + [3]=> + string(5) "world" +} +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +array(2) { + ["one"]=> + int(1) + ["two"]=> + int(2) +} +array(2) { + ["one"]=> + int(1) + ["two"]=> + int(2) +} +array(1) { + [1]=> + int(2) +} +array(1) { + ["two"]=> + int(2) +} +Done +--UEXPECTF-- +*** Testing array_intersect() : basic functionality *** +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + unicode(5) "hello" + [3]=> + unicode(5) "world" +} +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +array(2) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) +} +array(2) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) +} +array(1) { + [1]=> + int(2) +} +array(1) { + [u"two"]=> + int(2) +} +Done diff --git a/ext/standard/tests/array/array_intersect_error.phpt b/ext/standard/tests/array/array_intersect_error.phpt new file mode 100644 index 0000000000..507dd91b5a --- /dev/null +++ b/ext/standard/tests/array/array_intersect_error.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test array_intersect() function : error conditions +--FILE-- + +--EXPECTF-- +*** Testing array_intersect() : error conditions *** + +-- Testing array_intersect() function with Zero arguments -- + +Warning: array_intersect(): at least 2 parameters are required, 0 given in %s on line %d +NULL + +-- Testing array_intersect() function with less than expected no. of arguments -- + +Warning: array_intersect(): at least 2 parameters are required, 1 given in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing array_intersect() : error conditions *** + +-- Testing array_intersect() function with Zero arguments -- + +Warning: array_intersect(): at least 2 parameters are required, 0 given in %s on line %d +NULL + +-- Testing array_intersect() function with less than expected no. of arguments -- + +Warning: array_intersect(): at least 2 parameters are required, 1 given in %s on line %d +NULL +Done diff --git a/ext/standard/tests/array/array_intersect_variation1.phpt b/ext/standard/tests/array/array_intersect_variation1.phpt new file mode 100644 index 0000000000..95d14e3933 --- /dev/null +++ b/ext/standard/tests/array/array_intersect_variation1.phpt @@ -0,0 +1,451 @@ +--TEST-- +Test array_intersect() function : usage variations - unexpected values for 'arr1' argument +--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 diff --git a/ext/standard/tests/array/array_intersect_variation10.phpt b/ext/standard/tests/array/array_intersect_variation10.phpt new file mode 100644 index 0000000000..b4f44a574d --- /dev/null +++ b/ext/standard/tests/array/array_intersect_variation10.phpt @@ -0,0 +1,74 @@ +--TEST-- +Test array_intersect() function : usage variations - binary safe checking +--FILE-- + +--EXPECTF-- +*** Testing array_intersect() : 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() : 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_variation2.phpt b/ext/standard/tests/array/array_intersect_variation2.phpt new file mode 100644 index 0000000000..9887ac7d86 --- /dev/null +++ b/ext/standard/tests/array/array_intersect_variation2.phpt @@ -0,0 +1,452 @@ +--TEST-- +Test array_intersect() function : usage variations - unexpected values for 'arr2' argument +--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 $arr2 argument *** + +-- Iterator 1 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 2 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 3 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 4 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 5 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 6 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 7 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 8 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 9 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 10 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 11 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 12 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 13 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 14 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 15 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 16 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 17 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 18 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 19 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 20 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 21 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 22 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 23 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 24 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing array_intersect() : Passing non-array values to $arr2 argument *** + +-- Iterator 1 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 2 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 3 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 4 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 5 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 6 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 7 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 8 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 9 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 10 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 11 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 12 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 13 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 14 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 15 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 16 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 17 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 18 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 19 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 20 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 21 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 22 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 23 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +-- Iterator 24 -- +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_intersect(): Argument #2 is not an array in %s on line %d +NULL +Done diff --git a/ext/standard/tests/array/array_intersect_variation3.phpt b/ext/standard/tests/array/array_intersect_variation3.phpt new file mode 100644 index 0000000000..cde3db4ed2 --- /dev/null +++ b/ext/standard/tests/array/array_intersect_variation3.phpt @@ -0,0 +1,590 @@ +--TEST-- +Test array_intersect() 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), // array with default keys and numeric values + array(1.1, 2.2), // 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, $multiline_string, $diff_whitespaces, $numeric_string), // array 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, "hello", "one", NULL, 2, + 'world', true, false, false => 5, 'aaaa\r', "aaaa\r", + $numeric_string, $diff_whitespaces, + "one" => "ten", 4 => "four", "two" => 2, 2 => "two", + '', null => "null", '' => 'emptys' +); + +// loop through each sub-array within $arrrays to check the behavior of array_intersect() +$iterator = 1; +foreach($arrays as $arr1) { + echo "-- Iterator $iterator --\n"; + + // Calling array_intersect() with default arguments + var_dump( array_intersect($arr1, $arr2) ); + + // Calling array_intersect() with more arguments. + // additional argument passed is the same as $arr1 argument + var_dump( array_intersect($arr1, $arr2, $arr1) ); + $iterator++; +} + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_intersect() : Passing different types of arrays to $arr1 argument *** +-- Iterator 1 -- +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +-- Iterator 2 -- +array(1) { + [0]=> + float(1.1) +} +array(1) { + [0]=> + float(1.1) +} +-- Iterator 3 -- +array(2) { + [0]=> + bool(false) + [1]=> + bool(true) +} +array(2) { + [0]=> + bool(false) + [1]=> + bool(true) +} +-- Iterator 4 -- +array(0) { +} +array(0) { +} +-- Iterator 5 -- +array(1) { + [0]=> + NULL +} +array(1) { + [0]=> + NULL +} +-- Iterator 6 -- +array(1) { + [1]=> + string(5) "aaaa +" +} +array(1) { + [1]=> + string(5) "aaaa +" +} +-- Iterator 7 -- +array(1) { + [1]=> + string(6) "aaaa\r" +} +array(1) { + [1]=> + string(6) "aaaa\r" +} +-- Iterator 8 -- +array(2) { + [2]=> + string(88) "hello + world +1111 != 2222 +heredoc +double quoted string. with different white spaces" + [3]=> + string(90) "11 < 12. 123 >22 +'single quoted string' +"double quoted string" +2222 != 1111. 0000 = 0000 +" +} +array(2) { + [2]=> + string(88) "hello + world +1111 != 2222 +heredoc +double quoted string. with different white spaces" + [3]=> + string(90) "11 < 12. 123 >22 +'single quoted string' +"double quoted string" +2222 != 1111. 0000 = 0000 +" +} +-- Iterator 9 -- +array(2) { + [1]=> + string(3) "one" + [2]=> + string(3) "two" +} +array(2) { + [1]=> + string(3) "one" + [2]=> + string(3) "two" +} +-- Iterator 10 -- +array(2) { + ["one"]=> + int(1) + ["two"]=> + int(2) +} +array(2) { + ["one"]=> + int(1) + ["two"]=> + int(2) +} +-- Iterator 11 -- +array(0) { +} +array(0) { +} +-- Iterator 12 -- +array(1) { + ["one"]=> + string(3) "ten" +} +array(1) { + ["one"]=> + string(3) "ten" +} +-- Iterator 13 -- +array(3) { + ["one"]=> + int(1) + [2]=> + string(3) "two" + [4]=> + string(4) "four" +} +array(3) { + ["one"]=> + int(1) + [2]=> + string(3) "two" + [4]=> + string(4) "four" +} +-- Iterator 14 -- +array(2) { + ["NULL"]=> + NULL + ["null"]=> + NULL +} +array(2) { + ["NULL"]=> + NULL + ["null"]=> + NULL +} +-- Iterator 15 -- +array(2) { + ["false"]=> + bool(false) + ["true"]=> + bool(true) +} +array(2) { + ["false"]=> + bool(false) + ["true"]=> + bool(true) +} +-- Iterator 16 -- +array(3) { + [""]=> + string(6) "emptys" + ["emptyd"]=> + string(0) "" + ["emptys"]=> + string(0) "" +} +array(3) { + [""]=> + string(6) "emptys" + ["emptyd"]=> + string(0) "" + ["emptys"]=> + string(0) "" +} +-- Iterator 17 -- +array(6) { + [1]=> + string(0) "" + [2]=> + string(0) "" + [3]=> + NULL + [4]=> + NULL + [5]=> + bool(false) + [6]=> + bool(true) +} +array(6) { + [1]=> + string(0) "" + [2]=> + string(0) "" + [3]=> + NULL + [4]=> + NULL + [5]=> + bool(false) + [6]=> + bool(true) +} +-- Iterator 18 -- +array(1) { + [0]=> + int(5) +} +array(1) { + [0]=> + int(5) +} +-- Iterator 19 -- +array(0) { +} +array(0) { +} +Done +--UEXPECTF-- +*** Testing array_intersect() : Passing different types of arrays to $arr1 argument *** +-- Iterator 1 -- +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +-- Iterator 2 -- +array(1) { + [0]=> + float(1.1) +} +array(1) { + [0]=> + float(1.1) +} +-- Iterator 3 -- +array(2) { + [0]=> + bool(false) + [1]=> + bool(true) +} +array(2) { + [0]=> + bool(false) + [1]=> + bool(true) +} +-- Iterator 4 -- +array(0) { +} +array(0) { +} +-- Iterator 5 -- +array(1) { + [0]=> + NULL +} +array(1) { + [0]=> + NULL +} +-- Iterator 6 -- +array(1) { + [1]=> + unicode(5) "aaaa +" +} +array(1) { + [1]=> + unicode(5) "aaaa +" +} +-- Iterator 7 -- +array(1) { + [1]=> + unicode(6) "aaaa\r" +} +array(1) { + [1]=> + unicode(6) "aaaa\r" +} +-- Iterator 8 -- +array(2) { + [2]=> + unicode(88) "hello + world +1111 != 2222 +heredoc +double quoted string. with different white spaces" + [3]=> + unicode(90) "11 < 12. 123 >22 +'single quoted string' +"double quoted string" +2222 != 1111. 0000 = 0000 +" +} +array(2) { + [2]=> + unicode(88) "hello + world +1111 != 2222 +heredoc +double quoted string. with different white spaces" + [3]=> + unicode(90) "11 < 12. 123 >22 +'single quoted string' +"double quoted string" +2222 != 1111. 0000 = 0000 +" +} +-- Iterator 9 -- +array(2) { + [1]=> + unicode(3) "one" + [2]=> + unicode(3) "two" +} +array(2) { + [1]=> + unicode(3) "one" + [2]=> + unicode(3) "two" +} +-- Iterator 10 -- +array(2) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) +} +array(2) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) +} +-- Iterator 11 -- +array(0) { +} +array(0) { +} +-- Iterator 12 -- +array(1) { + [u"one"]=> + unicode(3) "ten" +} +array(1) { + [u"one"]=> + unicode(3) "ten" +} +-- Iterator 13 -- +array(3) { + [u"one"]=> + int(1) + [2]=> + unicode(3) "two" + [4]=> + unicode(4) "four" +} +array(3) { + [u"one"]=> + int(1) + [2]=> + unicode(3) "two" + [4]=> + unicode(4) "four" +} +-- Iterator 14 -- +array(2) { + [u"NULL"]=> + NULL + [u"null"]=> + NULL +} +array(2) { + [u"NULL"]=> + NULL + [u"null"]=> + NULL +} +-- Iterator 15 -- +array(2) { + [u"false"]=> + bool(false) + [u"true"]=> + bool(true) +} +array(2) { + [u"false"]=> + bool(false) + [u"true"]=> + bool(true) +} +-- Iterator 16 -- +array(3) { + [u""]=> + unicode(6) "emptys" + [u"emptyd"]=> + unicode(0) "" + [u"emptys"]=> + unicode(0) "" +} +array(3) { + [u""]=> + unicode(6) "emptys" + [u"emptyd"]=> + unicode(0) "" + [u"emptys"]=> + unicode(0) "" +} +-- Iterator 17 -- +array(6) { + [1]=> + unicode(0) "" + [2]=> + unicode(0) "" + [3]=> + NULL + [4]=> + NULL + [5]=> + bool(false) + [6]=> + bool(true) +} +array(6) { + [1]=> + unicode(0) "" + [2]=> + unicode(0) "" + [3]=> + NULL + [4]=> + NULL + [5]=> + bool(false) + [6]=> + bool(true) +} +-- Iterator 18 -- +array(1) { + [0]=> + int(5) +} +array(1) { + [0]=> + int(5) +} +-- Iterator 19 -- +array(0) { +} +array(0) { +} +Done diff --git a/ext/standard/tests/array/array_intersect_variation5.phpt b/ext/standard/tests/array/array_intersect_variation5.phpt new file mode 100644 index 0000000000..bea88f1dad --- /dev/null +++ b/ext/standard/tests/array/array_intersect_variation5.phpt @@ -0,0 +1,336 @@ +--TEST-- +Test array_intersect() 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(1, "float", "f4", "hello", 2.2, 'color', "string", "pen\n", 11); + +// loop through each sub-array within $arrrays to check the behavior of array_intersect() +$iterator = 1; +foreach($arrays as $arr1) { + echo "-- Iterator $iterator --\n"; + + // Calling array_intersect() with default arguments + var_dump( array_intersect($arr1, $arr2) ); + + // Calling array_intersect() with more arguments. + // additional argument passed is the same as $arr1 argument + var_dump( array_intersect($arr1, $arr2, $arr1) ); + $iterator++; +} + +// close the file resource used +fclose($fp); + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_intersect() : 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 +-- Iterator 1 -- +array(0) { +} +array(0) { +} +-- Iterator 2 -- +array(0) { +} +array(0) { +} +-- Iterator 3 -- +array(1) { + [1]=> + string(1) "1" +} +array(1) { + [1]=> + string(1) "1" +} +-- Iterator 4 -- +array(1) { + [1]=> + string(1) "1" +} +array(1) { + [1]=> + string(1) "1" +} +-- Iterator 5 -- +array(1) { + [2]=> + string(5) "float" +} +array(1) { + [2]=> + string(5) "float" +} +-- Iterator 6 -- +array(1) { + [33333333]=> + string(2) "f4" +} +array(1) { + [33333333]=> + string(2) "f4" +} +-- Iterator 7 -- +array(2) { + ["re\td"]=> + string(5) "color" + ["\v\fworld"]=> + float(2.2) +} +array(2) { + ["re\td"]=> + string(5) "color" + ["\v\fworld"]=> + float(2.2) +} +-- Iterator 8 -- +array(2) { + ["re d"]=> + string(5) "color" + [" world"]=> + float(2.2) +} +array(2) { + ["re d"]=> + string(5) "color" + [" world"]=> + float(2.2) +} +-- Iterator 9 -- +array(2) { + [0]=> + string(5) "hello" + ["Hello world"]=> + string(6) "string" +} +array(2) { + [0]=> + string(5) "hello" + ["Hello world"]=> + string(6) "string" +} +-- Iterator 10 -- +array(1) { + [""]=> + string(5) "hello" +} +array(1) { + [""]=> + string(5) "hello" +} +-- Iterator 11 -- +array(3) { + ["hello"]=> + int(1) + ["fruit"]=> + float(2.2) + [444]=> + string(5) "float" +} +array(3) { + ["hello"]=> + int(1) + ["fruit"]=> + float(2.2) + [444]=> + string(5) "float" +} +Done +--UEXPECTF-- +*** Testing array_intersect() : 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 +-- Iterator 1 -- +array(0) { +} +array(0) { +} +-- Iterator 2 -- +array(0) { +} +array(0) { +} +-- Iterator 3 -- +array(1) { + [1]=> + unicode(1) "1" +} +array(1) { + [1]=> + unicode(1) "1" +} +-- Iterator 4 -- +array(1) { + [1]=> + unicode(1) "1" +} +array(1) { + [1]=> + unicode(1) "1" +} +-- Iterator 5 -- +array(1) { + [2]=> + unicode(5) "float" +} +array(1) { + [2]=> + unicode(5) "float" +} +-- Iterator 6 -- +array(1) { + [33333333]=> + unicode(2) "f4" +} +array(1) { + [33333333]=> + unicode(2) "f4" +} +-- Iterator 7 -- +array(2) { + [u"re\td"]=> + unicode(5) "color" + [u"\v\fworld"]=> + float(2.2) +} +array(2) { + [u"re\td"]=> + unicode(5) "color" + [u"\v\fworld"]=> + float(2.2) +} +-- Iterator 8 -- +array(2) { + [u"re d"]=> + unicode(5) "color" + [u" world"]=> + float(2.2) +} +array(2) { + [u"re d"]=> + unicode(5) "color" + [u" world"]=> + float(2.2) +} +-- Iterator 9 -- +array(2) { + [0]=> + unicode(5) "hello" + [u"Hello world"]=> + unicode(6) "string" +} +array(2) { + [0]=> + unicode(5) "hello" + [u"Hello world"]=> + unicode(6) "string" +} +-- Iterator 10 -- +array(1) { + [u""]=> + unicode(5) "hello" +} +array(1) { + [u""]=> + unicode(5) "hello" +} +-- Iterator 11 -- +array(3) { + [u"hello"]=> + int(1) + [u"fruit"]=> + float(2.2) + [444]=> + unicode(5) "float" +} +array(3) { + [u"hello"]=> + int(1) + [u"fruit"]=> + float(2.2) + [444]=> + unicode(5) "float" +} +Done diff --git a/ext/standard/tests/array/array_intersect_variation6.phpt b/ext/standard/tests/array/array_intersect_variation6.phpt new file mode 100644 index 0000000000..2e148f3590 --- /dev/null +++ b/ext/standard/tests/array/array_intersect_variation6.phpt @@ -0,0 +1,336 @@ +--TEST-- +Test array_intersect() 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(1, "float", "f4", "hello", 2.2, 'color', "string", "pen\n", 11); + +// loop through each sub-array within $arrrays to check the behavior of array_intersect() +$iterator = 1; +foreach($arrays as $arr2) { + echo "-- Iterator $iterator --\n"; + + // Calling array_intersect() with default arguments + var_dump( array_intersect($arr1, $arr2) ); + + // Calling array_intersect() with more arguments. + // additional argument passed is the same as $arr1 argument + var_dump( array_intersect($arr1, $arr2, $arr1) ); + $iterator++; +} + +// close the file resource used +fclose($fp); + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_intersect() : 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 +-- Iterator 1 -- +array(0) { +} +array(0) { +} +-- Iterator 2 -- +array(0) { +} +array(0) { +} +-- Iterator 3 -- +array(1) { + [0]=> + int(1) +} +array(1) { + [0]=> + int(1) +} +-- Iterator 4 -- +array(1) { + [0]=> + int(1) +} +array(1) { + [0]=> + int(1) +} +-- Iterator 5 -- +array(1) { + [1]=> + string(5) "float" +} +array(1) { + [1]=> + string(5) "float" +} +-- Iterator 6 -- +array(1) { + [2]=> + string(2) "f4" +} +array(1) { + [2]=> + string(2) "f4" +} +-- Iterator 7 -- +array(2) { + [4]=> + float(2.2) + [5]=> + string(5) "color" +} +array(2) { + [4]=> + float(2.2) + [5]=> + string(5) "color" +} +-- Iterator 8 -- +array(2) { + [4]=> + float(2.2) + [5]=> + string(5) "color" +} +array(2) { + [4]=> + float(2.2) + [5]=> + string(5) "color" +} +-- Iterator 9 -- +array(2) { + [3]=> + string(5) "hello" + [6]=> + string(6) "string" +} +array(2) { + [3]=> + string(5) "hello" + [6]=> + string(6) "string" +} +-- Iterator 10 -- +array(1) { + [3]=> + string(5) "hello" +} +array(1) { + [3]=> + string(5) "hello" +} +-- Iterator 11 -- +array(3) { + [0]=> + int(1) + [1]=> + string(5) "float" + [4]=> + float(2.2) +} +array(3) { + [0]=> + int(1) + [1]=> + string(5) "float" + [4]=> + float(2.2) +} +Done +--UEXPECTF-- +*** Testing array_intersect() : 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 +-- Iterator 1 -- +array(0) { +} +array(0) { +} +-- Iterator 2 -- +array(0) { +} +array(0) { +} +-- Iterator 3 -- +array(1) { + [0]=> + int(1) +} +array(1) { + [0]=> + int(1) +} +-- Iterator 4 -- +array(1) { + [0]=> + int(1) +} +array(1) { + [0]=> + int(1) +} +-- Iterator 5 -- +array(1) { + [1]=> + unicode(5) "float" +} +array(1) { + [1]=> + unicode(5) "float" +} +-- Iterator 6 -- +array(1) { + [2]=> + unicode(2) "f4" +} +array(1) { + [2]=> + unicode(2) "f4" +} +-- Iterator 7 -- +array(2) { + [4]=> + float(2.2) + [5]=> + unicode(5) "color" +} +array(2) { + [4]=> + float(2.2) + [5]=> + unicode(5) "color" +} +-- Iterator 8 -- +array(2) { + [4]=> + float(2.2) + [5]=> + unicode(5) "color" +} +array(2) { + [4]=> + float(2.2) + [5]=> + unicode(5) "color" +} +-- Iterator 9 -- +array(2) { + [3]=> + unicode(5) "hello" + [6]=> + unicode(6) "string" +} +array(2) { + [3]=> + unicode(5) "hello" + [6]=> + unicode(6) "string" +} +-- Iterator 10 -- +array(1) { + [3]=> + unicode(5) "hello" +} +array(1) { + [3]=> + unicode(5) "hello" +} +-- Iterator 11 -- +array(3) { + [0]=> + int(1) + [1]=> + unicode(5) "float" + [4]=> + float(2.2) +} +array(3) { + [0]=> + int(1) + [1]=> + unicode(5) "float" + [4]=> + float(2.2) +} +Done diff --git a/ext/standard/tests/array/array_intersect_variation7.phpt b/ext/standard/tests/array/array_intersect_variation7.phpt new file mode 100644 index 0000000000..2b216d0ee7 --- /dev/null +++ b/ext/standard/tests/array/array_intersect_variation7.phpt @@ -0,0 +1,333 @@ +--TEST-- +Test array_intersect() 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.333333), + + // 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(1, 2, 1.2, 2.3333, "col\tor", '\v\fworld', $fp, + "Hello world", $heredoc, new classA(), 444.432, "fruit"); + +// loop through each sub-array within $arrrays to check the behavior of array_intersect() +$iterator = 1; +foreach($arrays as $arr1) { + echo "-- Iterator $iterator --\n"; + + // Calling array_intersect() with default arguments + var_dump( array_intersect($arr1, $arr2) ); + + // Calling array_intersect() with more arguments. + // additional argument passed is the same as $arr1 argument + var_dump( array_intersect($arr1, $arr2, $arr1) ); + $iterator++; +} + +// close the file resource used +fclose($fp); + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_intersect() : assoc array with diff values to $arr1 argument *** +-- Iterator 1 -- +array(0) { +} +array(0) { +} +-- Iterator 2 -- +array(0) { +} +array(0) { +} +-- Iterator 3 -- +array(1) { + [1]=> + int(1) +} +array(1) { + [1]=> + int(1) +} +-- Iterator 4 -- +array(2) { + ["one"]=> + int(1) + ["two"]=> + int(2) +} +array(2) { + ["one"]=> + int(1) + ["two"]=> + int(2) +} +-- Iterator 5 -- +array(1) { + ["float"]=> + float(2.3333) +} +array(1) { + ["float"]=> + float(2.3333) +} +-- Iterator 6 -- +array(1) { + ["f1"]=> + float(1.2) +} +array(1) { + ["f1"]=> + float(1.2) +} +-- Iterator 7 -- +array(1) { + ["red"]=> + string(6) "col or" +} +array(1) { + ["red"]=> + string(6) "col or" +} +-- Iterator 8 -- +array(1) { + [2]=> + string(9) "\v\fworld" +} +array(1) { + [2]=> + string(9) "\v\fworld" +} +-- Iterator 9 -- +array(1) { + ["heredoc"]=> + string(11) "Hello world" +} +array(1) { + ["heredoc"]=> + string(11) "Hello world" +} +-- Iterator 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) +} +-- Iterator 11 -- +array(5) { + [2]=> + object(classA)#%d (0) { + } + [222]=> + string(5) "fruit" + ["resource"]=> + resource(%d) of type (stream) + ["float"]=> + float(444.432) + ["heredoc"]=> + string(11) "Hello world" +} +array(5) { + [2]=> + object(classA)#%d (0) { + } + [222]=> + string(5) "fruit" + ["resource"]=> + resource(%d) of type (stream) + ["float"]=> + float(444.432) + ["heredoc"]=> + string(11) "Hello world" +} +Done +--UEXPECTF-- +*** Testing array_intersect() : assoc array with diff values to $arr1 argument *** +-- Iterator 1 -- +array(0) { +} +array(0) { +} +-- Iterator 2 -- +array(0) { +} +array(0) { +} +-- Iterator 3 -- +array(1) { + [1]=> + int(1) +} +array(1) { + [1]=> + int(1) +} +-- Iterator 4 -- +array(2) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) +} +array(2) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) +} +-- Iterator 5 -- +array(1) { + [u"float"]=> + float(2.3333) +} +array(1) { + [u"float"]=> + float(2.3333) +} +-- Iterator 6 -- +array(1) { + [u"f1"]=> + float(1.2) +} +array(1) { + [u"f1"]=> + float(1.2) +} +-- Iterator 7 -- +array(1) { + [u"red"]=> + unicode(6) "col or" +} +array(1) { + [u"red"]=> + unicode(6) "col or" +} +-- Iterator 8 -- +array(1) { + [2]=> + unicode(9) "\v\fworld" +} +array(1) { + [2]=> + unicode(9) "\v\fworld" +} +-- Iterator 9 -- +array(1) { + [u"heredoc"]=> + unicode(11) "Hello world" +} +array(1) { + [u"heredoc"]=> + unicode(11) "Hello world" +} +-- Iterator 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) +} +-- Iterator 11 -- +array(5) { + [2]=> + object(classA)#%d (0) { + } + [222]=> + unicode(5) "fruit" + [u"resource"]=> + resource(%d) of type (stream) + [u"float"]=> + float(444.432) + [u"heredoc"]=> + unicode(11) "Hello world" +} +array(5) { + [2]=> + object(classA)#%d (0) { + } + [222]=> + unicode(5) "fruit" + [u"resource"]=> + resource(%d) of type (stream) + [u"float"]=> + float(444.432) + [u"heredoc"]=> + unicode(11) "Hello world" +} +Done diff --git a/ext/standard/tests/array/array_intersect_variation8.phpt b/ext/standard/tests/array/array_intersect_variation8.phpt new file mode 100644 index 0000000000..1a92cf06d0 --- /dev/null +++ b/ext/standard/tests/array/array_intersect_variation8.phpt @@ -0,0 +1,349 @@ +--TEST-- +Test array_intersect() 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.333333), + + // 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(1, 2, 1.2, 2.3333, "col\tor", '\v\fworld', $fp, + "Hello world", $heredoc, new classA(), 444.432, "fruit"); + +// loop through each sub-array within $arrrays to check the behavior of array_intersect() +$iterator = 1; +foreach($arrays as $arr2) { + echo "-- Iterator $iterator --\n"; + + // Calling array_intersect() with default arguments + var_dump( array_intersect($arr1, $arr2) ); + + // Calling array_intersect() with more arguments. + // additional argument passed is the same as $arr1 argument + var_dump( array_intersect($arr1, $arr2, $arr1) ); + $iterator++; +} + +// close the file resource used +fclose($fp); + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_intersect() : assoc array with diff values to $arr2 argument *** +-- Iterator 1 -- +array(0) { +} +array(0) { +} +-- Iterator 2 -- +array(0) { +} +array(0) { +} +-- Iterator 3 -- +array(1) { + [0]=> + int(1) +} +array(1) { + [0]=> + int(1) +} +-- Iterator 4 -- +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +-- Iterator 5 -- +array(1) { + [3]=> + float(2.3333) +} +array(1) { + [3]=> + float(2.3333) +} +-- Iterator 6 -- +array(1) { + [2]=> + float(1.2) +} +array(1) { + [2]=> + float(1.2) +} +-- Iterator 7 -- +array(1) { + [4]=> + string(6) "col or" +} +array(1) { + [4]=> + string(6) "col or" +} +-- Iterator 8 -- +array(1) { + [5]=> + string(9) "\v\fworld" +} +array(1) { + [5]=> + string(9) "\v\fworld" +} +-- Iterator 9 -- +array(2) { + [7]=> + string(11) "Hello world" + [8]=> + string(11) "Hello world" +} +array(2) { + [7]=> + string(11) "Hello world" + [8]=> + string(11) "Hello world" +} +-- Iterator 10 -- +array(2) { + [6]=> + resource(%d) of type (stream) + [9]=> + object(classA)#%d (0) { + } +} +array(2) { + [6]=> + resource(%d) of type (stream) + [9]=> + object(classA)#%d (0) { + } +} +-- Iterator 11 -- +array(6) { + [6]=> + resource(%d) of type (stream) + [7]=> + string(11) "Hello world" + [8]=> + string(11) "Hello world" + [9]=> + object(classA)#%d (0) { + } + [10]=> + float(444.432) + [11]=> + string(5) "fruit" +} +array(6) { + [6]=> + resource(%d) of type (stream) + [7]=> + string(11) "Hello world" + [8]=> + string(11) "Hello world" + [9]=> + object(classA)#%d (0) { + } + [10]=> + float(444.432) + [11]=> + string(5) "fruit" +} +Done +--UEXPECTF-- +*** Testing array_intersect() : assoc array with diff values to $arr2 argument *** +-- Iterator 1 -- +array(0) { +} +array(0) { +} +-- Iterator 2 -- +array(0) { +} +array(0) { +} +-- Iterator 3 -- +array(1) { + [0]=> + int(1) +} +array(1) { + [0]=> + int(1) +} +-- Iterator 4 -- +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +-- Iterator 5 -- +array(1) { + [3]=> + float(2.3333) +} +array(1) { + [3]=> + float(2.3333) +} +-- Iterator 6 -- +array(1) { + [2]=> + float(1.2) +} +array(1) { + [2]=> + float(1.2) +} +-- Iterator 7 -- +array(1) { + [4]=> + unicode(6) "col or" +} +array(1) { + [4]=> + unicode(6) "col or" +} +-- Iterator 8 -- +array(1) { + [5]=> + unicode(9) "\v\fworld" +} +array(1) { + [5]=> + unicode(9) "\v\fworld" +} +-- Iterator 9 -- +array(2) { + [7]=> + unicode(11) "Hello world" + [8]=> + unicode(11) "Hello world" +} +array(2) { + [7]=> + unicode(11) "Hello world" + [8]=> + unicode(11) "Hello world" +} +-- Iterator 10 -- +array(2) { + [6]=> + resource(%d) of type (stream) + [9]=> + object(classA)#%d (0) { + } +} +array(2) { + [6]=> + resource(%d) of type (stream) + [9]=> + object(classA)#%d (0) { + } +} +-- Iterator 11 -- +array(6) { + [6]=> + resource(%d) of type (stream) + [7]=> + unicode(11) "Hello world" + [8]=> + unicode(11) "Hello world" + [9]=> + object(classA)#%d (0) { + } + [10]=> + float(444.432) + [11]=> + unicode(5) "fruit" +} +array(6) { + [6]=> + resource(%d) of type (stream) + [7]=> + unicode(11) "Hello world" + [8]=> + unicode(11) "Hello world" + [9]=> + object(classA)#%d (0) { + } + [10]=> + float(444.432) + [11]=> + unicode(5) "fruit" +} +Done diff --git a/ext/standard/tests/array/array_intersect_variation9.phpt b/ext/standard/tests/array/array_intersect_variation9.phpt new file mode 100644 index 0000000000..b2ab136383 --- /dev/null +++ b/ext/standard/tests/array/array_intersect_variation9.phpt @@ -0,0 +1,333 @@ +--TEST-- +Test array_intersect() function : usage variations - two dimensional arrays for $arr1 and $arr2 arguments(Bug#43109) +--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() with default arguments +echo "-- Passing the entire 2-D array to \$arr1 and \$arr2 --\n"; +echo "- With default arguments -\n"; +var_dump( array_intersect($arr1, $arr2) ); + +// Calling array_intersect() with more arguments +// additional argument passed is the same as $arr1 +echo "- With more arguments -\n"; +var_dump( array_intersect($arr1, $arr2, $arr1) ); + +/* Passing the sub-array as argument to $arr1 and $arr2 */ +// Calling array_intersect() with default arguments +echo "-- Passing the sub-array to \$arr1 and \$arr2 --\n"; +echo "- With default arguments -\n"; +var_dump( array_intersect($arr1[0], $arr2[0]) ); + +// Calling array_intersect() with more arguments +// additional argument passed is the same as $arr1 +echo "- With more arguments -\n"; +var_dump( array_intersect($arr1[0], $arr2[0], $arr1[0]) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_intersect() : 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 + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d +array(4) { + [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) + } + [2]=> + array(3) { + [1]=> + string(3) "one" + [2]=> + string(3) "two" + [3]=> + string(5) "three" + } + [3]=> + array(3) { + ["ten"]=> + int(10) + ["twenty"]=> + float(20) + ["thirty"]=> + int(30) + } +} +- 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 + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +array(4) { + [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) + } + [2]=> + array(3) { + [1]=> + string(3) "one" + [2]=> + string(3) "two" + [3]=> + string(5) "three" + } + [3]=> + array(3) { + ["ten"]=> + int(10) + ["twenty"]=> + float(20) + ["thirty"]=> + int(30) + } +} +-- 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() : 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 + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d +array(4) { + [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) + } + [2]=> + array(3) { + [1]=> + unicode(3) "one" + [2]=> + unicode(3) "two" + [3]=> + unicode(5) "three" + } + [3]=> + array(3) { + [u"ten"]=> + int(10) + [u"twenty"]=> + float(20) + [u"thirty"]=> + int(30) + } +} +- 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 + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d +array(4) { + [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) + } + [2]=> + array(3) { + [1]=> + unicode(3) "one" + [2]=> + unicode(3) "two" + [3]=> + unicode(5) "three" + } + [3]=> + array(3) { + [u"ten"]=> + int(10) + [u"twenty"]=> + float(20) + [u"thirty"]=> + int(30) + } +} +-- 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