--- /dev/null
+--TEST--
+Test array_diff_assoc() function : basic functionality
+--FILE--
+<?php
+/* Prototype : array array_diff_assoc(array $arr1, array $arr2 [, array ...])
+ * Description: Returns the entries of $arr1 that have values which are not
+ * present in any of the others arguments but do additional checks whether the keys are equal
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Test basic functionality of array_diff_assoc
+ */
+
+echo "*** Testing array_diff_assoc() : basic functionality ***\n";
+$array_default_key = array('one', 2, 'three', '4');
+$array_numeric_key = array(1 => 'one', 2=> 'two', 3 => 4);
+$array_string_key = array('one' => 1, 'two' => '2', '3' => 'three');
+
+
+
+echo "-- Compare Default keys to numeric keys --\n";
+var_dump(array_diff_assoc($array_default_key, $array_numeric_key));
+var_dump(array_diff_assoc($array_numeric_key, $array_default_key));
+
+
+echo "\n-- Compare Default keys to string keys --\n";
+var_dump(array_diff_assoc($array_default_key, $array_numeric_key));
+var_dump(array_diff_assoc($array_numeric_key, $array_default_key));
+
+
+echo "\n-- Compare numeric keys to string keys --\n";
+var_dump(array_diff_assoc($array_numeric_key, $array_string_key));
+var_dump(array_diff_assoc($array_string_key, $array_numeric_key));
+
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing array_diff_assoc() : basic functionality ***
+-- Compare Default keys to numeric keys --
+array(3) {
+ [0]=>
+ string(3) "one"
+ [1]=>
+ int(2)
+ [2]=>
+ string(5) "three"
+}
+array(2) {
+ [1]=>
+ string(3) "one"
+ [2]=>
+ string(3) "two"
+}
+
+-- Compare Default keys to string keys --
+array(3) {
+ [0]=>
+ string(3) "one"
+ [1]=>
+ int(2)
+ [2]=>
+ string(5) "three"
+}
+array(2) {
+ [1]=>
+ string(3) "one"
+ [2]=>
+ string(3) "two"
+}
+
+-- Compare numeric keys to string keys --
+array(3) {
+ [1]=>
+ string(3) "one"
+ [2]=>
+ string(3) "two"
+ [3]=>
+ int(4)
+}
+array(3) {
+ ["one"]=>
+ int(1)
+ ["two"]=>
+ string(1) "2"
+ [3]=>
+ string(5) "three"
+}
+Done
--- /dev/null
+--TEST--
+Test array_diff_assoc() function : error conditions - pass array_diff_assoc() too few/zero arguments
+--FILE--
+<?php
+/* Prototype : array array_diff_assoc(array $arr1, array $arr2 [, array ...])
+ * Description: Returns the entries of arr1 that have values which are not present
+ * in any of the others arguments but do additional checks whether the keys are equal
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Test errors for array_diff with too few\zero arguments
+ */
+
+echo "*** Testing array_diff_assoc() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing array_diff() function with zero arguments --\n";
+var_dump( array_diff_assoc() );
+
+// Testing array_diff_assoc with one less than the expected number of arguments
+echo "\n-- Testing array_diff_assoc() function with less than expected no. of arguments --\n";
+$arr1 = array(1, 2);
+var_dump( array_diff_assoc($arr1) );
+
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing array_diff_assoc() : error conditions ***
+
+-- Testing array_diff() function with zero arguments --
+NULL
+
+-- Testing array_diff_assoc() function with less than expected no. of arguments --
+NULL
+Done
\ No newline at end of file
--- /dev/null
+--TEST--
+Test array_diff_assoc() function : usage variations - unexpected values for 'arr1' argument
+--FILE--
+<?php
+/* Prototype : array array_diff_assoc(array $arr1, array $arr2 [, array ...])
+ * Description: Returns the entries of $arr1 that have values which are not present
+ * in any of the others arguments but do additional checks whether the keys are equal
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Pass array_diff_assoc arguments that are not arrays in place of $arr1
+ */
+
+echo "*** Testing array_diff_assoc() : usage variations ***\n";
+
+$array = array(1, 2, 3);
+
+//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");
+
+//array of unexpected values to be passed to $arr1 argument
+$inputs = 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,
+
+ // binary data
+/*21*/ b"binary",
+ (binary)"binary",
+
+ // object data
+/*23*/ new classA(),
+
+ // undefined data
+/*24*/ @$undefined_var,
+
+ // unset data
+/*25*/ @$unset_var,
+
+ // resource variable
+/*26*/ $fp,
+);
+
+// loop through each element of $inputs to check the behavior of array_diff_assoc
+$iterator = 1;
+foreach($inputs as $input) {
+ echo "\n-- Iteration $iterator --\n";
+ var_dump( array_diff_assoc($input, $array));
+ $iterator++;
+};
+fclose($fp);
+echo "Done";
+?>
+
+--EXPECTF--
+*** Testing array_diff_assoc() : usage variations ***
+
+-- Iteration 1 --
+
+Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
+NULL
+
+-- Iteration 2 --
+
+Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
+NULL
+
+-- Iteration 3 --
+
+Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
+NULL
+
+-- Iteration 4 --
+
+Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
+NULL
+
+-- Iteration 5 --
+
+Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
+NULL
+
+-- Iteration 6 --
+
+Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
+NULL
+
+-- Iteration 7 --
+
+Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
+NULL
+
+-- Iteration 8 --
+
+Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
+NULL
+
+-- Iteration 9 --
+
+Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
+NULL
+
+-- Iteration 10 --
+
+Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
+NULL
+
+-- Iteration 11 --
+
+Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
+NULL
+
+-- Iteration 12 --
+
+Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
+NULL
+
+-- Iteration 13 --
+
+Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
+NULL
+
+-- Iteration 14 --
+
+Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
+NULL
+
+-- Iteration 15 --
+
+Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
+NULL
+
+-- Iteration 16 --
+
+Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
+NULL
+
+-- Iteration 17 --
+
+Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
+NULL
+
+-- Iteration 18 --
+
+Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
+NULL
+
+-- Iteration 19 --
+
+Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
+NULL
+
+-- Iteration 20 --
+
+Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
+NULL
+
+-- Iteration 21 --
+
+Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
+NULL
+
+-- Iteration 22 --
+
+Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
+NULL
+
+-- Iteration 23 --
+
+Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
+NULL
+
+-- Iteration 24 --
+
+Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
+NULL
+
+-- Iteration 25 --
+
+Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
+NULL
+
+-- Iteration 26 --
+
+Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
+NULL
+Done
\ No newline at end of file
--- /dev/null
+--TEST--
+Test array_diff_assoc() function : usage variations - binary safe check
+--FILE--
+<?php
+/* Prototype : array array_diff_assoc(array $arr1, array $arr2 [, array ...])
+ * Description: Returns the entries of arr1 that have values which are not
+ * present in any of the others arguments but do additional checks whether
+ * the keys are equal
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Test how array_diff_assoc() compares binary data
+ */
+
+echo "*** Testing array_diff_assoc() : usage variations ***\n";
+
+$array1 = array( b"1",
+ b"hello",
+ "world",
+ "str1" => "hello",
+ "str2" => "world");
+
+$array2 = array( b"1" => 'hello',
+ b"world",
+ "hello",
+ 'test');
+
+var_dump(array_diff_assoc($array1, $array2));
+var_dump(array_diff_assoc($array2, $array1));
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing array_diff_assoc() : usage variations ***
+array(3) {
+ [0]=>
+ string(1) "1"
+ ["str1"]=>
+ string(5) "hello"
+ ["str2"]=>
+ string(5) "world"
+}
+array(2) {
+ [3]=>
+ string(5) "hello"
+ [4]=>
+ string(4) "test"
+}
+Done
--- /dev/null
+--TEST--
+Test array_diff_assoc() function : usage variations - unexpected values for 'arr1' argument
+--FILE--
+<?php
+/* Prototype : array array_diff_assoc(array $arr1, array $arr2 [, array ...])
+ * Description: Returns the entries of arr1 that have values which are not present
+ * in any of the others arguments but do additional checks whether the keys are equal
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * pass array_diff_assoc arguments which are not arrays in place of $arr2
+ */
+
+echo "\n*** Testing array_diff_assoc() : usage variations ***\n";
+
+$array = array(1, 2, 3);
+
+//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");
+
+//array of unexpected values to be passed to $arr1 argument
+$inputs = 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,
+
+ // binary data
+/*21*/ b"binary",
+ (binary)"binary",
+
+ // object data
+/*23*/ new classA(),
+
+ // undefined data
+/*24*/ @$undefined_var,
+
+ // unset data
+/*25*/ @$unset_var,
+
+ // resource variable
+/*26*/ $fp,
+);
+
+// loop through each element of $inputs to check the behavior of array_diff_assoc
+$iterator = 1;
+foreach($inputs as $input) {
+ echo "\n-- Iteration $iterator --\n";
+ var_dump( array_diff_assoc($array, $input));
+ $iterator++;
+};
+fclose($fp);
+echo "Done";
+?>
+
+--EXPECTF--
+
+*** Testing array_diff_assoc() : usage variations ***
+
+-- Iteration 1 --
+
+Warning: array_diff_assoc(): Argument #2 is not an array in %s on line %d
+NULL
+
+-- Iteration 2 --
+
+Warning: array_diff_assoc(): Argument #2 is not an array in %s on line %d
+NULL
+
+-- Iteration 3 --
+
+Warning: array_diff_assoc(): Argument #2 is not an array in %s on line %d
+NULL
+
+-- Iteration 4 --
+
+Warning: array_diff_assoc(): Argument #2 is not an array in %s on line %d
+NULL
+
+-- Iteration 5 --
+
+Warning: array_diff_assoc(): Argument #2 is not an array in %s on line %d
+NULL
+
+-- Iteration 6 --
+
+Warning: array_diff_assoc(): Argument #2 is not an array in %s on line %d
+NULL
+
+-- Iteration 7 --
+
+Warning: array_diff_assoc(): Argument #2 is not an array in %s on line %d
+NULL
+
+-- Iteration 8 --
+
+Warning: array_diff_assoc(): Argument #2 is not an array in %s on line %d
+NULL
+
+-- Iteration 9 --
+
+Warning: array_diff_assoc(): Argument #2 is not an array in %s on line %d
+NULL
+
+-- Iteration 10 --
+
+Warning: array_diff_assoc(): Argument #2 is not an array in %s on line %d
+NULL
+
+-- Iteration 11 --
+
+Warning: array_diff_assoc(): Argument #2 is not an array in %s on line %d
+NULL
+
+-- Iteration 12 --
+
+Warning: array_diff_assoc(): Argument #2 is not an array in %s on line %d
+NULL
+
+-- Iteration 13 --
+
+Warning: array_diff_assoc(): Argument #2 is not an array in %s on line %d
+NULL
+
+-- Iteration 14 --
+
+Warning: array_diff_assoc(): Argument #2 is not an array in %s on line %d
+NULL
+
+-- Iteration 15 --
+
+Warning: array_diff_assoc(): Argument #2 is not an array in %s on line %d
+NULL
+
+-- Iteration 16 --
+
+Warning: array_diff_assoc(): Argument #2 is not an array in %s on line %d
+NULL
+
+-- Iteration 17 --
+
+Warning: array_diff_assoc(): Argument #2 is not an array in %s on line %d
+NULL
+
+-- Iteration 18 --
+
+Warning: array_diff_assoc(): Argument #2 is not an array in %s on line %d
+NULL
+
+-- Iteration 19 --
+
+Warning: array_diff_assoc(): Argument #2 is not an array in %s on line %d
+NULL
+
+-- Iteration 20 --
+
+Warning: array_diff_assoc(): Argument #2 is not an array in %s on line %d
+NULL
+
+-- Iteration 21 --
+
+Warning: array_diff_assoc(): Argument #2 is not an array in %s on line %d
+NULL
+
+-- Iteration 22 --
+
+Warning: array_diff_assoc(): Argument #2 is not an array in %s on line %d
+NULL
+
+-- Iteration 23 --
+
+Warning: array_diff_assoc(): Argument #2 is not an array in %s on line %d
+NULL
+
+-- Iteration 24 --
+
+Warning: array_diff_assoc(): Argument #2 is not an array in %s on line %d
+NULL
+
+-- Iteration 25 --
+
+Warning: array_diff_assoc(): Argument #2 is not an array in %s on line %d
+NULL
+
+-- Iteration 26 --
+
+Warning: array_diff_assoc(): Argument #2 is not an array in %s on line %d
+NULL
+Done
\ No newline at end of file
--- /dev/null
+--TEST--
+Test array_diff_assoc() function : variation - array containing different data types
+--FILE--
+<?php
+/* Prototype : array array_diff_assoc(array $arr1, array $arr2 [, array ...])
+ * Description: Returns the entries of arr1 that have values which are not present
+ * in any of the others arguments but do additional checks whether the keys are equal
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Test how array_diff_assoc() compares indexed arrays containing different data types
+ */
+
+echo "\n*** Testing array_diff_assoc() : usage variations ***\n";
+
+$array = array(1, 2, 3);
+
+//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;
+
+//array of different data types to be passed to $arr1 argument
+$inputs = array(
+
+ // int data
+/*1*/
+'int' => array(
+ 0,
+ 1,
+ 12345,
+ -2345),
+
+ // float data
+/*2*/
+'float' => array(
+ 10.5,
+ -10.5,
+ 12.3456789000e10,
+ 12.3456789000E-10,
+ .5),
+
+ // null data
+/*3*/
+'null' => array(
+ NULL,
+ null),
+
+ // boolean data
+/*4*/
+'bool' => array(
+ true,
+ false,
+ TRUE,
+ FALSE),
+
+ // empty data
+/*5*/
+'empty' => array(
+ "",
+ ''),
+
+ // string data
+/*6*/
+'string' => array(
+ "string",
+ 'string',
+ $heredoc),
+
+ // binary data
+/*7*/
+'binary' => array(
+ b"binary",
+ (binary)"binary"),
+
+ // object data
+/*8*/
+'object' => array(
+ new classA()),
+
+ // undefined data
+/*9*/
+'undefined' => array(
+ @$undefined_var),
+
+ // unset data
+/*10*/
+'unset' => array(
+ @$unset_var),
+);
+
+// loop through each element of $inputs to check the behavior of array_diff_assoc
+$iterator = 1;
+foreach($inputs as $key => $input) {
+ echo "\n-- Iteration $iterator --\n";
+ var_dump( array_diff_assoc($input, $array));
+ $iterator++;
+};
+echo "Done";
+?>
+--EXPECTF--
+
+*** Testing array_diff_assoc() : usage variations ***
+
+-- Iteration 1 --
+array(4) {
+ [0]=>
+ int(0)
+ [1]=>
+ int(1)
+ [2]=>
+ int(12345)
+ [3]=>
+ int(-2345)
+}
+
+-- Iteration 2 --
+array(5) {
+ [0]=>
+ float(10.5)
+ [1]=>
+ float(-10.5)
+ [2]=>
+ float(123456789000)
+ [3]=>
+ float(1.23456789E-9)
+ [4]=>
+ float(0.5)
+}
+
+-- Iteration 3 --
+array(2) {
+ [0]=>
+ NULL
+ [1]=>
+ NULL
+}
+
+-- Iteration 4 --
+array(3) {
+ [1]=>
+ bool(false)
+ [2]=>
+ bool(true)
+ [3]=>
+ bool(false)
+}
+
+-- Iteration 5 --
+array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(0) ""
+}
+
+-- Iteration 6 --
+array(3) {
+ [0]=>
+ string(6) "string"
+ [1]=>
+ string(6) "string"
+ [2]=>
+ string(11) "hello world"
+}
+
+-- Iteration 7 --
+array(2) {
+ [0]=>
+ string(6) "binary"
+ [1]=>
+ string(6) "binary"
+}
+
+-- Iteration 8 --
+array(1) {
+ [0]=>
+ object(classA)#%d (0) {
+ }
+}
+
+-- Iteration 9 --
+array(1) {
+ [0]=>
+ NULL
+}
+
+-- Iteration 10 --
+array(1) {
+ [0]=>
+ NULL
+}
+Done
--- /dev/null
+--TEST--
+Test array_diff_assoc() function : usage variations - arrays with different data types as keys
+--FILE--
+
+<?php
+/* Prototype : array array_diff_assoc(array $arr1, array $arr2 [, array ...])
+ * Description: Returns the entries of arr1 that have values which are not present
+ * in any of the others arguments but do additional checks whether the keys are equal
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Test how array_diff_assoc() compares arrays containing different data types
+ * as keys
+ */
+
+echo "\n*** Testing array_diff_assoc() : usage variations ***\n";
+
+$array = array(1, 2, 3);
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+//Different data types as keys to be passed to $arr1 argument
+$inputs = array(
+
+ // int data
+/*1*/
+'int' => array(
+ 0 => 'zero',
+ 1 => 'one',
+ 12345 => 'positive',
+ -2345 => 'negative'),
+
+ // float data
+/*2*/
+'float' => array(
+ 10.5 => 'float 1',
+ -10.5 => 'float 2',
+ .5 => 'float 3'),
+
+ // null data
+/*3*/
+'null' => array(
+ NULL => 'null 1',
+ null => 'null 2'),
+
+ // boolean data
+/*4*/
+'bool' => array(
+ true => 'boolt',
+ false => 'boolf',
+ TRUE => 'boolT',
+ FALSE => 'boolF'),
+
+ // empty data
+/*5*/
+'empty' => array(
+ "" => 'emptyd',
+ '' => 'emptys'),
+
+ // string data
+/*6*/
+'string' => array(
+ "string" => 'stringd',
+ 'string' => 'strings',
+ $heredoc => 'stringh'),
+
+ // binary data
+/*7*/
+'binary' => array(
+ b"binary1" => 'binary 1',
+ (binary)"binary2" => 'binary 2'),
+
+ // undefined data
+/*8*/
+'undefined' => array(
+ @$undefined_var => 'undefined'),
+
+ // unset data
+/*9*/
+'unset' => array(
+ @$unset_var => 'unset'),
+
+);
+
+// loop through each element of $inputs to check the behavior of array_diff_assoc
+$iterator = 1;
+foreach($inputs as $key => $input) {
+ echo "\n-- Iteration $iterator --\n";
+ var_dump( array_diff_assoc($input, $array));
+ $iterator++;
+};
+
+echo "Done";
+?>
+
+--EXPECTF--
+
+*** Testing array_diff_assoc() : usage variations ***
+
+-- Iteration 1 --
+array(4) {
+ [0]=>
+ string(4) "zero"
+ [1]=>
+ string(3) "one"
+ [12345]=>
+ string(8) "positive"
+ [-2345]=>
+ string(8) "negative"
+}
+
+-- Iteration 2 --
+array(3) {
+ [10]=>
+ string(7) "float 1"
+ [-10]=>
+ string(7) "float 2"
+ [0]=>
+ string(7) "float 3"
+}
+
+-- Iteration 3 --
+array(1) {
+ [""]=>
+ string(6) "null 2"
+}
+
+-- Iteration 4 --
+array(2) {
+ [1]=>
+ string(5) "boolT"
+ [0]=>
+ string(5) "boolF"
+}
+
+-- Iteration 5 --
+array(1) {
+ [""]=>
+ string(6) "emptys"
+}
+
+-- Iteration 6 --
+array(2) {
+ ["string"]=>
+ string(7) "strings"
+ ["hello world"]=>
+ string(7) "stringh"
+}
+
+-- Iteration 7 --
+array(2) {
+ ["binary1"]=>
+ string(8) "binary 1"
+ ["binary2"]=>
+ string(8) "binary 2"
+}
+
+-- Iteration 8 --
+array(1) {
+ [""]=>
+ string(9) "undefined"
+}
+
+-- Iteration 9 --
+array(1) {
+ [""]=>
+ string(5) "unset"
+}
+Done
\ No newline at end of file
--- /dev/null
+--TEST--
+Test array_diff_assoc() function : usage variations - compare integers, floats and strings
+--FILE--
+<?php
+/* Prototype : array array_diff_assoc(array $arr1, array $arr2 [, array ...])
+ * Description: Returns the entries of arr1 that have values which are not present
+ * in any of the others arguments but do additional checks whether the keys are equal
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Test how array_diff_assoc compares integers, floats and string
+ */
+
+echo "*** Testing array_diff_assoc() : usage variations ***\n";
+$arr_default_int = array(1, 2, 3, 'a');
+$arr_float = array(0 => 1.00, 1.00 => 2.00, 2.00 => 3.00, 'b');
+$arr_string = array('1', '2', '3', 'c');
+$arr_string_float = array('0' => '1.00', '1.00' => '2.00', '2.00' => '3.00', 'd');
+
+echo "-- Result of comparing integers and floating point numbers: --\n";
+var_dump(array_diff_assoc($arr_default_int, $arr_float));
+var_dump(array_diff_assoc($arr_float, $arr_default_int));
+
+echo "-- Result of comparing integers and strings containing an integers : --\n";
+var_dump(array_diff_assoc($arr_default_int, $arr_string));
+var_dump(array_diff_assoc($arr_string, $arr_default_int));
+
+echo "-- Result of comparing integers and strings containing floating points : --\n";
+var_dump(array_diff_assoc($arr_default_int, $arr_string_float));
+var_dump(array_diff_assoc($arr_string_float, $arr_default_int));
+
+echo "-- Result of comparing floating points and strings containing integers : --\n";
+var_dump(array_diff_assoc($arr_float, $arr_string));
+var_dump(array_diff_assoc($arr_string, $arr_float));
+
+echo "-- Result of comparing floating points and strings containing floating point: --\n";
+var_dump(array_diff_assoc($arr_float, $arr_string_float));
+var_dump(array_diff_assoc($arr_string_float, $arr_float));
+
+echo "-- Result of comparing strings containing integers and strings containing floating points : --\n";
+var_dump(array_diff_assoc($arr_string, $arr_string_float));
+var_dump(array_diff_assoc($arr_string_float, $arr_string));
+
+echo "-- Result of comparing more than two arrays: --\n";
+var_dump(array_diff_assoc($arr_default_int, $arr_float, $arr_string, $arr_string_float));
+
+echo "Done";
+?>
+--EXPECTF--
+
+*** Testing array_diff_assoc() : usage variations ***
+-- Result of comparing integers and floating point numbers: --
+array(1) {
+ [3]=>
+ string(1) "a"
+}
+array(1) {
+ [3]=>
+ string(1) "b"
+}
+-- Result of comparing integers and strings containing an integers : --
+array(1) {
+ [3]=>
+ string(1) "a"
+}
+array(1) {
+ [3]=>
+ string(1) "c"
+}
+-- Result of comparing integers and strings containing floating points : --
+array(4) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ [3]=>
+ string(1) "a"
+}
+array(4) {
+ [0]=>
+ string(4) "1.00"
+ ["1.00"]=>
+ string(4) "2.00"
+ ["2.00"]=>
+ string(4) "3.00"
+ [1]=>
+ string(1) "d"
+}
+-- Result of comparing floating points and strings containing integers : --
+array(1) {
+ [3]=>
+ string(1) "b"
+}
+array(1) {
+ [3]=>
+ string(1) "c"
+}
+-- Result of comparing floating points and strings containing floating point: --
+array(4) {
+ [0]=>
+ float(1)
+ [1]=>
+ float(2)
+ [2]=>
+ float(3)
+ [3]=>
+ string(1) "b"
+}
+array(4) {
+ [0]=>
+ string(4) "1.00"
+ ["1.00"]=>
+ string(4) "2.00"
+ ["2.00"]=>
+ string(4) "3.00"
+ [1]=>
+ string(1) "d"
+}
+-- Result of comparing strings containing integers and strings containing floating points : --
+array(4) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(1) "2"
+ [2]=>
+ string(1) "3"
+ [3]=>
+ string(1) "c"
+}
+array(4) {
+ [0]=>
+ string(4) "1.00"
+ ["1.00"]=>
+ string(4) "2.00"
+ ["2.00"]=>
+ string(4) "3.00"
+ [1]=>
+ string(1) "d"
+}
+-- Result of comparing more than two arrays: --
+array(1) {
+ [3]=>
+ string(1) "a"
+}
+Done
--- /dev/null
+--TEST--
+Test array_diff_assoc() function : usage variations - strict string comparison check
+--FILE--
+<?php
+/* Prototype : array array_diff_assoc(array $arr1, array $arr2 [, array ...])
+ * Description: Returns the entries of $arr1 that have values which are not
+ * present in any of the others arguments but do additional checks whether the keys are equal
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Test how array_diff_assoc behaves
+ * 1. When comparing an array that has similar elements
+ * but has been created in a different order
+ * 2. When doing a strict comparison of string representation
+ */
+
+echo "*** Testing array_diff_assoc() : usage variations ***\n";
+
+$array = array ('zero',
+ 1 => 1,
+ 'two' => 2.00000000000001);
+
+$inputs = array (
+
+//default keys => string values
+/*1*/ array('2.00000000000001', '1', 'zero', 'a'),
+
+//numeric keys => string values
+/*2*/ array(2 => '2.00000000000001',
+ 1 => '1',
+ 0 => 'zero',
+ 3 => 'a'),
+
+//string keys => string values
+/*3*/ array('2' => '2.00000000000001',
+ '1' => '1',
+ '0' => 'zero',
+ '3' => 'a') ,
+
+//default keys => numeric values
+/*4*/ array(2, 1, 0),
+
+//numeric keys => numeric values
+/*5*/ array(2 => 2,
+ 1 => 1,
+ 0 => 0),
+
+//string keys => numeric values
+/*6*/ array('two' => 2,
+ '1' => 1,
+ '0' => 0),
+
+//defualt keys => float values
+/*7*/ array(2.00000000000001, 1.00, 0.01E-9),
+
+//numeric keys => float values
+/*8*/ array(2 => 2.00000000000001,
+ 1 => 1.00,
+ 0 => 0.01E-9),
+
+//string keys => float values
+/*9*/ array ('two' => 2.00000000000001,
+ '1' => 1.00,
+ '0' =>0.01E-9)
+);
+
+// loop through each element of $inputs to check the behavior of array_diff_assoc
+$iterator = 1;
+foreach($inputs as $input) {
+ echo "\n-- Iteration $iterator --\n";
+ var_dump(array_diff_assoc($array, $input));
+ var_dump(array_diff_assoc($input, $array));
+ $iterator++;
+};
+echo "Done";
+?>
+--EXPECTF--
+*** Testing array_diff_assoc() : usage variations ***
+
+-- Iteration 1 --
+array(2) {
+ [0]=>
+ string(4) "zero"
+ ["two"]=>
+ float(2)
+}
+array(3) {
+ [0]=>
+ string(16) "2.00000000000001"
+ [2]=>
+ string(4) "zero"
+ [3]=>
+ string(1) "a"
+}
+
+-- Iteration 2 --
+array(1) {
+ ["two"]=>
+ float(2)
+}
+array(2) {
+ [2]=>
+ string(16) "2.00000000000001"
+ [3]=>
+ string(1) "a"
+}
+
+-- Iteration 3 --
+array(1) {
+ ["two"]=>
+ float(2)
+}
+array(2) {
+ [2]=>
+ string(16) "2.00000000000001"
+ [3]=>
+ string(1) "a"
+}
+
+-- Iteration 4 --
+array(2) {
+ [0]=>
+ string(4) "zero"
+ ["two"]=>
+ float(2)
+}
+array(2) {
+ [0]=>
+ int(2)
+ [2]=>
+ int(0)
+}
+
+-- Iteration 5 --
+array(2) {
+ [0]=>
+ string(4) "zero"
+ ["two"]=>
+ float(2)
+}
+array(2) {
+ [2]=>
+ int(2)
+ [0]=>
+ int(0)
+}
+
+-- Iteration 6 --
+array(1) {
+ [0]=>
+ string(4) "zero"
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+
+-- Iteration 7 --
+array(2) {
+ [0]=>
+ string(4) "zero"
+ ["two"]=>
+ float(2)
+}
+array(2) {
+ [0]=>
+ float(2)
+ [2]=>
+ float(1.0E-11)
+}
+
+-- Iteration 8 --
+array(2) {
+ [0]=>
+ string(4) "zero"
+ ["two"]=>
+ float(2)
+}
+array(2) {
+ [2]=>
+ float(2)
+ [0]=>
+ float(1.0E-11)
+}
+
+-- Iteration 9 --
+array(1) {
+ [0]=>
+ string(4) "zero"
+}
+array(1) {
+ [0]=>
+ float(1.0E-11)
+}
+Done
\ No newline at end of file
--- /dev/null
+--TEST--
+Test array_diff_assoc() function : usage variations - arrays containing referenced variables
+--FILE--
+
+<?php
+/* Prototype : array array_diff_assoc(array $arr1, array $arr2 [, array ...])
+ * Description: Returns the entries of $arr1 that have values which are not
+ * present in any of the others arguments but do additional checks whether the keys are equal
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Tests how array_diff_assoc compares
+ * 1. Referenced variables
+ * 2. Arrays that have been referenced to each other
+ */
+
+echo "*** Testing array_diff_assoc() : usage variations ***\n";
+
+$a = 'a';
+
+$arr1 = array('a', 'b', 'c', $a);
+$arr2 = array('a' => 1, 'b' => 2, 'c' => 3, &$a);
+
+echo "-- Results when \$a = $a: --\n";
+var_dump(array_diff_assoc($arr1, $arr2));
+var_dump(array_diff_assoc($arr2, $arr1));
+
+$a = 4;
+
+echo "-- Results when \$a has been changed to $a: --\n";
+var_dump(array_diff_assoc($arr1, $arr2));
+var_dump(array_diff_assoc($arr2, $arr1));
+
+$arr2 = &$arr1;
+
+echo "-- Results when \$arr2 is referenced to \$arr1 --\n";
+var_dump(array_diff_assoc($arr1, $arr2));
+var_dump(array_diff_assoc($arr2, $arr1));
+
+$arr1 = array('zero' => 'x', 'one' => 'y', 'two' => 'z');
+
+echo "-- Results when \$arr1 is changed --\n";
+var_dump(array_diff_assoc($arr1, $arr2));
+var_dump(array_diff_assoc($arr2, $arr1));
+
+echo "Done";
+?>
+
+--EXPECTF--
+
+*** Testing array_diff_assoc() : usage variations ***
+-- Results when $a = a: --
+array(3) {
+ [1]=>
+ string(1) "b"
+ [2]=>
+ string(1) "c"
+ [3]=>
+ string(1) "a"
+}
+array(3) {
+ ["a"]=>
+ int(1)
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+}
+-- Results when $a has been changed to 4: --
+array(4) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ string(1) "b"
+ [2]=>
+ string(1) "c"
+ [3]=>
+ string(1) "a"
+}
+array(4) {
+ ["a"]=>
+ int(1)
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ [0]=>
+ &int(4)
+}
+-- Results when $arr2 is referenced to $arr1 --
+array(0) {
+}
+array(0) {
+}
+-- Results when $arr1 is changed --
+array(0) {
+}
+array(0) {
+}
+Done
\ No newline at end of file
--- /dev/null
+--TEST--
+Test array_diff_assoc() function : usage variations - array containing duplicate keys and values
+--FILE--
+<?php
+/* Prototype : array array_diff_assoc(array $arr1, array $arr2 [, array ...])
+ * Description: Returns the entries of $arr1 that have values which are not
+ * present in any of the others arguments but do additional checks whether
+ * the keys are equal
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Test how array_diff_assoc() behaves when comparing:
+ * 1. the order of the array
+ * 2. duplicate values
+ * 3. duplicate key names
+ */
+
+echo "*** Testing array_diff_assoc() : variation ***\n";
+
+$array_index = array('a', 'b', 'c', 0 => 'd', 'b'); //duplicate key (0), duplicate value (b)
+$array_assoc = array ('2' => 'c', //same key=>value pair, different order
+ '1' => 'b',
+ '0' => 'a',
+ 'b' => '3', //key and value from array_index swapped
+ 'c' => 2); //same as above, using integer
+
+var_dump(array_diff_assoc($array_index, $array_assoc));
+var_dump(array_diff_assoc($array_assoc, $array_index));
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing array_diff_assoc() : variation ***
+array(2) {
+ [0]=>
+ string(1) "d"
+ [3]=>
+ string(1) "b"
+}
+array(3) {
+ [0]=>
+ string(1) "a"
+ ["b"]=>
+ string(1) "3"
+ ["c"]=>
+ int(2)
+}
+Done
--- /dev/null
+--TEST--
+Test array_diff_assoc() function : usage variations - compare multidimensional arrays
+--FILE--
+<?php
+/* Prototype : array array_diff_assoc(array $arr1, array $arr2 [, array ...])
+ * Description: Returns the entries of $arr1 that have values which are not
+ * present in any of the others arguments but do additional checks whether
+ * the keys are equal
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Test how array_diff_assoc behaves when comparing
+ * multi-dimensional arrays
+ */
+
+echo "*** Testing array_diff_assoc() : usage variations ***\n";
+
+$array1 = array('sub_array1' => array (1, 2, 3),
+ 'sub_array2' => array ('a', 'b', 'c'));
+$array2 = array('sub_arraya' => array (1, 3, 5),
+ 'sub_arrayb' => array ('a', 'z', 'y'));
+
+echo "-- Compare two 2-D arrays --\n";
+var_dump(array_diff_assoc($array1, $array2));
+var_dump(array_diff_assoc($array2, $array1));
+
+echo "\n-- Compare subarrays from two 2-D arrays --\n";
+var_dump(array_diff_assoc($array1['sub_array1'], $array2['sub_arraya']));
+var_dump(array_diff_assoc($array2['sub_arraya'], $array1['sub_array1']));
+var_dump(array_diff_assoc($array1['sub_array2'], $array2['sub_arrayb']));
+var_dump(array_diff_assoc($array2['sub_arrayb'], $array1['sub_array1']));
+
+echo "\n-- Compare a subarray from one 2-D array and one 2-D array --\n";
+var_dump(array_diff_assoc($array1['sub_array1'], $array2));
+var_dump(array_diff_assoc($array1, $array2['sub_arraya']));
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing array_diff_assoc() : usage variations ***
+-- Compare two 2-D arrays --
+array(2) {
+ ["sub_array1"]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ ["sub_array2"]=>
+ array(3) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ string(1) "b"
+ [2]=>
+ string(1) "c"
+ }
+}
+array(2) {
+ ["sub_arraya"]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(3)
+ [2]=>
+ int(5)
+ }
+ ["sub_arrayb"]=>
+ array(3) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ string(1) "z"
+ [2]=>
+ string(1) "y"
+ }
+}
+
+-- Compare subarrays from two 2-D arrays --
+array(2) {
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+array(2) {
+ [1]=>
+ int(3)
+ [2]=>
+ int(5)
+}
+array(2) {
+ [1]=>
+ string(1) "b"
+ [2]=>
+ string(1) "c"
+}
+array(3) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ string(1) "z"
+ [2]=>
+ string(1) "y"
+}
+
+-- Compare a subarray from one 2-D array and one 2-D array --
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+array(2) {
+ ["sub_array1"]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ ["sub_array2"]=>
+ array(3) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ string(1) "b"
+ [2]=>
+ string(1) "c"
+ }
+}
+Done
\ No newline at end of file