summaryrefslogtreecommitdiff
path: root/ext/standard/tests/array/array_merge_recursive_variation9.phpt
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/standard/tests/array/array_merge_recursive_variation9.phpt
downloadphp2-master.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/standard/tests/array/array_merge_recursive_variation9.phpt')
-rw-r--r--ext/standard/tests/array/array_merge_recursive_variation9.phpt117
1 files changed, 117 insertions, 0 deletions
diff --git a/ext/standard/tests/array/array_merge_recursive_variation9.phpt b/ext/standard/tests/array/array_merge_recursive_variation9.phpt
new file mode 100644
index 0000000..d51d2f8
--- /dev/null
+++ b/ext/standard/tests/array/array_merge_recursive_variation9.phpt
@@ -0,0 +1,117 @@
+--TEST--
+Test array_merge_recursive() function : usage variations - common key and value(Bug#43559)
+--FILE--
+<?php
+/* Prototype : array array_merge_recursive(array $arr1[, array $...])
+ * Description: Recursively merges elements from passed arrays into one array
+ * Source code: ext/standard/array.c
+*/
+
+/*
+ * Testing the functionality of array_merge_recursive() by passing
+ * arrays having common key and value.
+*/
+
+echo "*** Testing array_merge_recursive() : arrays with common key and value ***\n";
+
+/* initialize the array having duplicate values */
+
+// integer values
+$arr1 = array("a" => 1, "b" => 2);
+$arr2 = array("b" => 2, "c" => 4);
+echo "-- Integer values --\n";
+var_dump( array_merge_recursive($arr1, $arr2) );
+
+// float values
+$arr1 = array("a" => 1.1, "b" => 2.2);
+$arr2 = array("b" => 2.2, "c" => 3.3);
+echo "-- Float values --\n";
+var_dump( array_merge_recursive($arr1, $arr2) );
+
+// string values
+$arr1 = array("a" => "hello", "b" => "world");
+$arr2 = array("b" => "world", "c" => "string");
+echo "-- String values --\n";
+var_dump( array_merge_recursive($arr1, $arr2) );
+
+// boolean values
+$arr1 = array("a" => true, "b" => false);
+$arr2 = array("b" => false);
+echo "-- Boolean values --\n";
+var_dump( array_merge_recursive($arr1, $arr2) );
+
+// null values
+$arr1 = array( "a" => NULL);
+$arr2 = array( "a" => NULL);
+echo "-- Null values --\n";
+var_dump( array_merge_recursive($arr1, $arr2) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing array_merge_recursive() : arrays with common key and value ***
+-- Integer values --
+array(3) {
+ ["a"]=>
+ int(1)
+ ["b"]=>
+ array(2) {
+ [0]=>
+ int(2)
+ [1]=>
+ int(2)
+ }
+ ["c"]=>
+ int(4)
+}
+-- Float values --
+array(3) {
+ ["a"]=>
+ float(1.1)
+ ["b"]=>
+ array(2) {
+ [0]=>
+ float(2.2)
+ [1]=>
+ float(2.2)
+ }
+ ["c"]=>
+ float(3.3)
+}
+-- String values --
+array(3) {
+ ["a"]=>
+ string(5) "hello"
+ ["b"]=>
+ array(2) {
+ [0]=>
+ string(5) "world"
+ [1]=>
+ string(5) "world"
+ }
+ ["c"]=>
+ string(6) "string"
+}
+-- Boolean values --
+array(2) {
+ ["a"]=>
+ bool(true)
+ ["b"]=>
+ array(2) {
+ [0]=>
+ bool(false)
+ [1]=>
+ bool(false)
+ }
+}
+-- Null values --
+array(1) {
+ ["a"]=>
+ array(2) {
+ [0]=>
+ NULL
+ [1]=>
+ NULL
+ }
+}
+Done