]> granicus.if.org Git - php/commitdiff
New testcases for array_intersect() function
authorRaghubansh Kumar <kraghuba@php.net>
Sat, 27 Oct 2007 12:15:16 +0000 (12:15 +0000)
committerRaghubansh Kumar <kraghuba@php.net>
Sat, 27 Oct 2007 12:15:16 +0000 (12:15 +0000)
12 files changed:
ext/standard/tests/array/array_intersect_basic.phpt [new file with mode: 0644]
ext/standard/tests/array/array_intersect_error.phpt [new file with mode: 0644]
ext/standard/tests/array/array_intersect_variation1.phpt [new file with mode: 0644]
ext/standard/tests/array/array_intersect_variation10.phpt [new file with mode: 0644]
ext/standard/tests/array/array_intersect_variation2.phpt [new file with mode: 0644]
ext/standard/tests/array/array_intersect_variation3.phpt [new file with mode: 0644]
ext/standard/tests/array/array_intersect_variation4.phpt [new file with mode: 0644]
ext/standard/tests/array/array_intersect_variation5.phpt [new file with mode: 0644]
ext/standard/tests/array/array_intersect_variation6.phpt [new file with mode: 0644]
ext/standard/tests/array/array_intersect_variation7.phpt [new file with mode: 0644]
ext/standard/tests/array/array_intersect_variation8.phpt [new file with mode: 0644]
ext/standard/tests/array/array_intersect_variation9.phpt [new file with mode: 0644]

diff --git a/ext/standard/tests/array/array_intersect_basic.phpt b/ext/standard/tests/array/array_intersect_basic.phpt
new file mode 100644 (file)
index 0000000..fde5782
--- /dev/null
@@ -0,0 +1,80 @@
+--TEST--
+Test array_intersect() function : basic functionality
+--FILE--
+<?php
+/* Prototype  : array array_intersect(array $arr1, array $arr2 [, array $...])
+ * Description: Returns the entries of arr1 that have values which are present in all the other arguments 
+ * Source code: ext/standard/array.c
+*/
+
+/*
+* Testing the behavior of array_intersect() by passing different arrays for the arguments. 
+* Function is tested by passing associative array as well as array with default keys.
+*/
+
+echo "*** Testing array_intersect() : basic functionality ***\n";
+
+// array with default keys
+$arr_default_keys = array(1, 2, "hello", 'world');
+
+// associative array
+$arr_associative = array("one" => 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
diff --git a/ext/standard/tests/array/array_intersect_error.phpt b/ext/standard/tests/array/array_intersect_error.phpt
new file mode 100644 (file)
index 0000000..5161a1c
--- /dev/null
@@ -0,0 +1,35 @@
+--TEST--
+Test array_intersect() function : error conditions 
+--FILE--
+<?php
+/* Prototype  : array array_intersect(array $arr1, array $arr2 [, array $...])
+ * Description: Returns the entries of arr1 that have values which are present in all the other arguments 
+ * Source code: ext/standard/array.c
+*/
+
+echo "*** Testing array_intersect() : error conditions ***\n";
+
+// Testing array_intersect() with zero arguments
+echo "\n-- Testing array_intersect() function with Zero arguments --\n";
+var_dump( array_intersect() );
+
+// Testing array_intersect() with one less than the expected number of arguments
+echo "\n-- Testing array_intersect() function with less than expected no. of arguments --\n";
+$arr1 = array(1, 2);
+var_dump( array_intersect($arr1) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing array_intersect() : error conditions ***
+
+-- Testing array_intersect() function with Zero arguments --
+
+Warning: Wrong parameter count for array_intersect() in %s on line %d
+NULL
+
+-- Testing array_intersect() function with less than expected no. of arguments --
+
+Warning: Wrong parameter count for array_intersect() 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 (file)
index 0000000..ca203ff
--- /dev/null
@@ -0,0 +1,280 @@
+--TEST--
+Test array_intersect() function : usage variations - unexpected values for 'arr1' argument
+--FILE--
+<?php
+/* Prototype  : array array_intersect(array $arr1, array $arr2 [, array $...])
+ * Description: Returns the entries of arr1 that have values which are present in all the other arguments 
+ * Source code: ext/standard/array.c
+*/
+
+/*
+* Testing array_intersect() function by passing values to $arr1 argument other than arrays
+* and see that function emits proper warning messages wherever expected.
+* The $arr2 argument is a fixed array.
+*/
+
+echo "*** Testing array_intersect() : Passing non-array values to \$arr1 argument ***\n";
+
+// array to be passsed to $arr2 as default argument
+$arr2 = array(1, 2);
+
+// array to be passed to optional argument
+$arr3 = array(1, 2, "one" => 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 = <<<EOT
+hello world
+EOT;
+
+// get a resource variable
+$fp = fopen(__FILE__, "r");
+
+// unexpected values to be passed to $arr1 argument
+$arrays = array(
+
+       // int data
+/*1*/  0,
+       1,
+       12345,
+       -2345,
+
+       // float data
+/*5*/  10.5,
+       -10.5,
+       12.3456789000e10,
+       12.3456789000E-10,
+       .5,
+
+       // null data
+/*10*/ NULL,
+       null,
+
+       // boolean data
+/*12*/ true,
+       false,
+       TRUE,
+       FALSE,
+
+       // empty data
+/*16*/ "",
+       '',
+       // string data
+/*18*/ "string",
+       'string',
+       $heredoc,
+
+       // object data
+/*21*/ new classA(),
+
+       // undefined data
+/*22*/ @$undefined_var,
+
+       // unset data
+/*23*/ @$unset_var,
+
+       // resource variable
+/*24*/ $fp
+);
+
+// loop through each sub-array within $arrrays to check the behavior of array_intersect()
+$iterator = 1;
+foreach($arrays as $unexpected_value) {
+  echo "\n-- Iterator $iterator --";
+  
+  // Calling array_intersect() with default arguments
+  var_dump( array_intersect($unexpected_value,$arr2) );
+
+  // Calling array_intersect() with more arguments
+  var_dump( array_intersect($unexpected_value, $arr2, $arr3) );
+  $iterator++;
+}
+
+// close the file resource used
+fclose($fp);
+
+echo "Done";
+?>
+--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
diff --git a/ext/standard/tests/array/array_intersect_variation10.phpt b/ext/standard/tests/array/array_intersect_variation10.phpt
new file mode 100644 (file)
index 0000000..e193f97
--- /dev/null
@@ -0,0 +1,53 @@
+--TEST--
+Test array_intersect() function : usage variations - binary safe checking 
+--FILE--
+<?php
+/* Prototype  : array array_intersect(array $arr1, array $arr2 [, array $...])
+ * Description: Returns the entries of arr1 that have values which are present in all the other arguments 
+ * Source code: ext/standard/array.c
+*/
+
+/*
+* Testing the behavior of array_intersect() by passing array with 
+* binary values for $arr1 and $arr2 argument. 
+*/
+
+echo "*** Testing array_intersect() : binary safe checking ***\n";
+
+// array with binary values
+$arr_binary = array(b"hello", b"world");
+// simple array
+$arr_normal = array("hello", "world");
+
+// array with binary value for $arr1 argument
+var_dump( array_intersect($arr_binary, $arr_normal) );
+
+// array with binary value for $arr2 argument
+var_dump( array_intersect($arr_normal, $arr_binary) );
+
+// array with binary value for both $arr1 and $arr2 argument
+var_dump( array_intersect($arr_binary, $arr_binary) );
+
+echo "Done";
+?>
+--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
diff --git a/ext/standard/tests/array/array_intersect_variation2.phpt b/ext/standard/tests/array/array_intersect_variation2.phpt
new file mode 100644 (file)
index 0000000..b690fc9
--- /dev/null
@@ -0,0 +1,281 @@
+--TEST--
+Test array_intersect() function : usage variations - unexpected values for 'arr2' argument
+--FILE--
+<?php
+/* Prototype  : array array_intersect(array $arr1, array $arr2 [, array $...])
+ * Description: Returns the entries of arr1 that have values which are present in all the other arguments 
+ * Source code: ext/standard/array.c
+*/
+
+/*
+* Testing array_intersect() function by passing values to $arr2 argument other than arrays
+* and see that function emits proper warning messages wherever expected.
+* The $arr1 argument is a fixed array.
+*/
+
+echo "*** Testing array_intersect() : Passing non-array values to \$arr2 argument ***\n";
+
+// array to be passsed to $arr1 as default argument
+$arr1 = array(1, 2);
+
+// arrays to be passed to optional argument
+$arr3 = array(1, 2, "one" => 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 = <<<EOT
+hello world
+EOT;
+
+// get a resource variable
+$fp = fopen(__FILE__, "r");
+
+// unexpected values to be passed to $arr2 argument
+$arrays = array(
+
+       // int data
+/*1*/  0,
+       1,
+       12345,
+       -2345,
+
+       // float data
+/*5*/  10.5,
+       -10.5,
+       12.3456789000e10,
+       12.3456789000E-10,
+       .5,
+
+       // null data
+/*10*/ NULL,
+       null,
+
+       // boolean data
+/*12*/ true,
+       false,
+       TRUE,
+       FALSE,
+
+       // empty data
+/*16*/ "",
+       '',
+       // string data
+/*18*/ "string",
+       'string',
+       $heredoc,
+
+       // object data
+/*21*/ new classA(),
+
+       // undefined data
+/*22*/ @$undefined_var,
+
+       // unset data
+/*23*/ @$unset_var,
+
+       // resource variable
+/*24*/ $fp
+);
+
+// loop through each sub-array within $arrrays to check the behavior of array_intersect()
+$iterator = 1;
+foreach($arrays as $unexpected_value) {
+  echo "\n-- Iterator $iterator --";
+  
+  // Calling array_intersect() with default arguments
+  var_dump( array_intersect($arr1,$unexpected_value) );
+
+  // Calling array_intersect() with more arguments
+  var_dump( array_intersect($arr1, $unexpected_value, $arr3) );
+
+  $iterator++;
+}
+
+// close the file resource used
+fclose($fp);
+
+echo "Done";
+?>
+--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
diff --git a/ext/standard/tests/array/array_intersect_variation3.phpt b/ext/standard/tests/array/array_intersect_variation3.phpt
new file mode 100644 (file)
index 0000000..b40366b
--- /dev/null
@@ -0,0 +1,346 @@
+--TEST--
+Test array_intersect() function : usage variations - different arrays for 'arr1' argument
+--FILE--
+<?php
+/* Prototype  : array array_intersect(array $arr1, array $arr2 [, array $...])
+ * Description: Returns the entries of arr1 that have values which are present in all the other arguments 
+ * Source code: ext/standard/array.c
+*/
+
+/*
+* Passing different types of arrays to $arr1 argument and testing whether 
+* array_intersect() behaves in expected way with the other arguments passed to the function
+* The $arr2 argument is a fixed array.
+*/
+
+echo "*** Testing array_intersect() : Passing different types of arrays to \$arr1 argument ***\n";
+
+/* Different heredoc strings passed as argument to $arr1 */
+// heredoc with blank line
+$blank_line = <<<EOT
+
+
+EOT;
+
+// heredoc with multiline string
+$multiline_string = <<<EOT
+hello world
+The big brown fox jumped over;
+the lazy dog
+This is a double quoted string
+EOT;
+
+// heredoc with diferent whitespaces
+$diff_whitespaces = <<<EOT
+hello\r world\t
+1111\t\t != 2222\v\v
+heredoc\ndouble quoted string. with\vdifferent\fwhite\vspaces
+EOT;
+
+// heredoc with quoted strings and numeric values
+$numeric_string = <<<EOT
+11 < 12. 123 >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\v\v
+heredoc
+double quoted string. with\vdifferent\fwhite\vspaces"
+  [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\v\v
+heredoc
+double quoted string. with\vdifferent\fwhite\vspaces"
+  [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
diff --git a/ext/standard/tests/array/array_intersect_variation4.phpt b/ext/standard/tests/array/array_intersect_variation4.phpt
new file mode 100644 (file)
index 0000000..2f1a341
--- /dev/null
@@ -0,0 +1,353 @@
+--TEST--
+Test array_intersect() function : usage variations - different arrays for 'arr2' argument
+--FILE--
+<?php
+/* Prototype  : array array_intersect(array $arr1, array $arr2 [, array $...])
+ * Description: Returns the entries of arr1 that have values which are present in all the other arguments 
+ * Source code: ext/standard/array.c
+*/
+
+/*
+* Passing different types of arrays to $arr2 argument and testing whether 
+* array_intersect() behaves in expected way with the other arguments passed to the function.  
+* The $arr1 argument is a fixed array.
+*/
+
+echo "*** Testing array_intersect() : Passing different types of arrays to \$arr2 argument ***\n";
+
+/* Different heredoc strings passed as argument to $arr2 */
+// heredoc with blank line
+$blank_line = <<<EOT
+
+
+EOT;
+
+// heredoc with multiline string
+$multiline_string = <<<EOT
+hello world
+The big brown fox jumped over;
+the lazy dog
+This is a double quoted string
+EOT;
+
+// heredoc with diferent whitespaces
+$diff_whitespaces = <<<EOT
+hello\r world\t
+1111\t\t != 2222\v\v
+heredoc\ndouble quoted string. with\vdifferent\fwhite\vspaces
+EOT;
+
+// heredoc with quoted strings and numeric values
+$numeric_string = <<<EOT
+11 < 12. 123 >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, "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'
+);
+
+// arrays to be passed to $arr2 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)
+);
+
+// loop through each sub-array within $arrrays to check the behavior of array_intersect()
+$iterator = 1;
+foreach($arrays as $arr2) {
+  echo "-- Iteration $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 $arr2 argument ***
+-- Iteration 1 --
+array(3) {
+  [5]=>
+  int(2)
+  [7]=>
+  bool(true)
+  ["two"]=>
+  int(2)
+}
+array(3) {
+  [5]=>
+  int(2)
+  [7]=>
+  bool(true)
+  ["two"]=>
+  int(2)
+}
+-- Iteration 2 --
+array(1) {
+  [1]=>
+  float(1.1)
+}
+array(1) {
+  [1]=>
+  float(1.1)
+}
+-- Iteration 3 --
+array(3) {
+  [7]=>
+  bool(true)
+  [8]=>
+  bool(false)
+  [13]=>
+  string(0) ""
+}
+array(3) {
+  [7]=>
+  bool(true)
+  [8]=>
+  bool(false)
+  [13]=>
+  string(0) ""
+}
+-- Iteration 4 --
+array(0) {
+}
+array(0) {
+}
+-- Iteration 5 --
+array(2) {
+  [8]=>
+  bool(false)
+  [13]=>
+  string(0) ""
+}
+array(2) {
+  [8]=>
+  bool(false)
+  [13]=>
+  string(0) ""
+}
+-- Iteration 6 --
+array(1) {
+  [10]=>
+  string(5) "aaaa
+"
+}
+array(1) {
+  [10]=>
+  string(5) "aaaa
+"
+}
+-- Iteration 7 --
+array(1) {
+  [9]=>
+  string(6) "aaaa\r"
+}
+array(1) {
+  [9]=>
+  string(6) "aaaa\r"
+}
+-- Iteration 8 --
+array(2) {
+  [11]=>
+  string(90) "11 < 12. 123 >22
+'single quoted string'
+"double quoted string"
+2222 != 1111.   0000 = 0000
+"
+  [12]=>
+  string(88) "hello
+ world 
+1111            != 2222\v\v
+heredoc
+double quoted string. with\vdifferent\fwhite\vspaces"
+}
+array(2) {
+  [11]=>
+  string(90) "11 < 12. 123 >22
+'single quoted string'
+"double quoted string"
+2222 != 1111.   0000 = 0000
+"
+  [12]=>
+  string(88) "hello
+ world 
+1111            != 2222\v\v
+heredoc
+double quoted string. with\vdifferent\fwhite\vspaces"
+}
+-- Iteration 9 --
+array(2) {
+  [2]=>
+  string(3) "two"
+  [3]=>
+  string(3) "one"
+}
+array(2) {
+  [2]=>
+  string(3) "two"
+  [3]=>
+  string(3) "one"
+}
+-- Iteration 10 --
+array(3) {
+  [5]=>
+  int(2)
+  [7]=>
+  bool(true)
+  ["two"]=>
+  int(2)
+}
+array(3) {
+  [5]=>
+  int(2)
+  [7]=>
+  bool(true)
+  ["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(3) {
+  [2]=>
+  string(3) "two"
+  [4]=>
+  string(4) "four"
+  [7]=>
+  bool(true)
+}
+array(3) {
+  [2]=>
+  string(3) "two"
+  [4]=>
+  string(4) "four"
+  [7]=>
+  bool(true)
+}
+-- Iteration 14 --
+array(2) {
+  [8]=>
+  bool(false)
+  [13]=>
+  string(0) ""
+}
+array(2) {
+  [8]=>
+  bool(false)
+  [13]=>
+  string(0) ""
+}
+-- Iteration 15 --
+array(3) {
+  [7]=>
+  bool(true)
+  [8]=>
+  bool(false)
+  [13]=>
+  string(0) ""
+}
+array(3) {
+  [7]=>
+  bool(true)
+  [8]=>
+  bool(false)
+  [13]=>
+  string(0) ""
+}
+-- Iteration 16 --
+array(3) {
+  [8]=>
+  bool(false)
+  [13]=>
+  string(0) ""
+  [""]=>
+  string(6) "emptys"
+}
+array(3) {
+  [8]=>
+  bool(false)
+  [13]=>
+  string(0) ""
+  [""]=>
+  string(6) "emptys"
+}
+-- Iteration 17 --
+array(3) {
+  [7]=>
+  bool(true)
+  [8]=>
+  bool(false)
+  [13]=>
+  string(0) ""
+}
+array(3) {
+  [7]=>
+  bool(true)
+  [8]=>
+  bool(false)
+  [13]=>
+  string(0) ""
+}
+-- Iteration 18 --
+array(1) {
+  [0]=>
+  int(5)
+}
+array(1) {
+  [0]=>
+  int(5)
+}
+-- Iteration 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 (file)
index 0000000..7f36ee3
--- /dev/null
@@ -0,0 +1,214 @@
+--TEST--
+Test array_intersect() function : usage variations - assoc array with diff keys for 'arr1' argument
+--FILE--
+<?php
+/* Prototype  : array array_intersect(array $arr1, array $arr2 [, array $...])
+ * Description: Returns the entries of arr1 that have values which are present in all the other arguments 
+ * Source code: ext/standard/array.c
+*/
+
+/*
+ * Testing the functionality of array_intersect() by passing different
+ * associative arrays having different possible keys to $arr1 argument.
+ * The $arr2 argument is a fixed array
+*/
+
+echo "*** Testing array_intersect() : assoc array with diff keys to \$arr1 argument ***\n";
+
+// get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// get a resource variable
+$fp = fopen(__FILE__, "r");
+
+// get a class
+class classA
+{
+  public function __toString(){
+    return "Class A object";
+  }
+}
+
+// get a heredoc string
+$heredoc = <<<EOT
+Hello world
+EOT;
+
+// different variations of associative arrays to be passed to $arr1 argument
+$arrays = array (
+
+       // empty array
+/*1*/  array(),
+
+       // arrays with integer keys
+       array(0 => "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"
+  ["\v\fworld"]=>
+  float(2.2)
+}
+array(2) {
+  ["re d"]=>
+  string(5) "color"
+  ["\v\fworld"]=>
+  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
diff --git a/ext/standard/tests/array/array_intersect_variation6.phpt b/ext/standard/tests/array/array_intersect_variation6.phpt
new file mode 100644 (file)
index 0000000..cecde34
--- /dev/null
@@ -0,0 +1,214 @@
+--TEST--
+Test array_intersect() function : usage variations - assoc array with diff keys for 'arr2' argument
+--FILE--
+<?php
+/* Prototype  : array array_intersect(array $arr1, array $arr2 [, array $...])
+ * Description: Returns the entries of arr1 that have values which are present in all the other arguments 
+ * Source code: ext/standard/array.c
+*/
+
+/*
+ * Testing the functionality of array_intersect() by passing different
+ * associative arrays having different possible keys to $arr2 argument.
+ * The $arr1 argument is a fixed array.
+*/
+
+echo "*** Testing array_intersect() : assoc array with diff keys to \$arr2 argument ***\n";
+
+// get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// get a resource variable
+$fp = fopen(__FILE__, "r");
+
+// get a class
+class classA
+{
+  public function __toString(){
+    return "Class A object";
+  }
+}
+
+// get a heredoc string
+$heredoc = <<<EOT
+Hello world
+EOT;
+
+// different variations of associative arrays to be passed to $arr2 argument
+$arrays = array (
+
+       // empty array
+/*1*/  array(),
+
+       // arrays with integer keys
+       array(0 => "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
diff --git a/ext/standard/tests/array/array_intersect_variation7.phpt b/ext/standard/tests/array/array_intersect_variation7.phpt
new file mode 100644 (file)
index 0000000..da1088c
--- /dev/null
@@ -0,0 +1,211 @@
+--TEST--
+Test array_intersect() function : usage variations - assoc array with diff values for 'arr1' argument
+--FILE--
+<?php
+/* Prototype  : array array_intersect(array $arr1, array $arr2 [, array $...])
+ * Description: Returns the entries of arr1 that have values which are present in all the other arguments 
+ * Source code: ext/standard/array.c
+*/
+
+/*
+ * Testing the functionality of array_intersect() by passing different
+ * associative arrays having different possible values to $arr1 argument.
+ * The $arr2 argument is a fixed array
+*/
+
+echo "*** Testing array_intersect() : assoc array with diff values to \$arr1 argument ***\n";
+
+// get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// get a resource variable
+$fp = fopen(__FILE__, "r");
+
+// get a class
+class classA
+{
+  public function __toString(){
+    return "Class A object";
+  }
+}
+
+// get a heredoc string
+$heredoc = <<<EOT
+Hello world
+EOT;
+
+// different variations of associative arrays to be passed to $arr1 argument
+$arrays = array (
+
+       // empty array
+/*1*/  array(),
+
+       // arrays with integer values
+       array('0' => 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
diff --git a/ext/standard/tests/array/array_intersect_variation8.phpt b/ext/standard/tests/array/array_intersect_variation8.phpt
new file mode 100644 (file)
index 0000000..91eae49
--- /dev/null
@@ -0,0 +1,219 @@
+--TEST--
+Test array_intersect() function : usage variations - assoc array with diff values for 'arr2' argument
+--FILE--
+<?php
+/* Prototype  : array array_intersect(array $arr1, array $arr2 [, array $...])
+ * Description: Returns the entries of arr1 that have values which are present in all the other arguments 
+ * Source code: ext/standard/array.c
+*/
+
+/*
+ * Testing the functionality of array_intersect() by passing different
+ * associative arrays having different possible values to $arr2 argument.
+ * The $arr1 argument is a fixed array.
+*/
+
+echo "*** Testing array_intersect() : assoc array with diff values to \$arr2 argument ***\n";
+
+// get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// get a resource variable
+$fp = fopen(__FILE__, "r");
+
+// get a class
+class classA
+{
+  public function __toString(){
+    return "Class A object";
+  }
+}
+
+// get a heredoc string
+$heredoc = <<<EOT
+Hello world
+EOT;
+
+// different variations of associative arrays to be passed to $arr2 argument
+$arrays = array (
+
+       // empty array
+/*1*/  array(),
+
+       // arrays with integer values
+       array('0' => 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
diff --git a/ext/standard/tests/array/array_intersect_variation9.phpt b/ext/standard/tests/array/array_intersect_variation9.phpt
new file mode 100644 (file)
index 0000000..ac3c887
--- /dev/null
@@ -0,0 +1,163 @@
+--TEST--
+Test array_intersect() function : usage variations - two dimensional arrays for $arr1 and $arr2 arguments 
+--FILE--
+<?php
+/* Prototype  : array array_intersect(array $arr1, array $arr2 [, array $...])
+ * Description: Returns the entries of arr1 that have values which are present in all the other arguments 
+ * Source code: ext/standard/array.c
+*/
+
+/*
+* Testing the behavior of array_intersect() by passing 2-D arrays
+* to both $arr1 and $arr2 argument. 
+* Optional argument takes the same value as that of $arr1
+*/
+
+echo "*** Testing array_intersect() : passing two dimensional array to both \$arr1 and \$arr2 arguments ***\n";
+
+// two dimensional arrays for $arr1 and $arr2 argument
+$arr1 = array (
+  
+  // arrays with default keys
+  array(1, 2, "hello", 'world'),
+  array(1, 2, 3, 4),
+
+  // arrays with explicit keys
+  array(1 => "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 -
+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 -
+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