From: =?utf-8?q?David_Pr=C3=A9vot?= <taffit@debian.org>
Date: Sun, 28 Sep 2014 15:40:45 -0400
Subject: Allow to compare arrays recursively

Author: Marius Ghita <mhitza@gmail.com>
Origin: other, https://stackoverflow.com/questions/3876435/recursive-array-diff#3877494
Forwarded: https://github.com/zetacomponents/ConsoleTools/pull/5
---
 tests/input_test.php | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/tests/input_test.php b/tests/input_test.php
index e0f58ee..07c84ca 100644
--- a/tests/input_test.php
+++ b/tests/input_test.php
@@ -2870,12 +2870,44 @@ class ezcConsoleInputTest extends ezcTestCase
             'ezcConsoleOptionExclusionViolationException'
         );
     }
+
+    private function arrayRecursiveDiff($aArray1, $aArray2)
+    {
+        $aReturn = array();
+
+        foreach ($aArray1 as $mKey => $mValue)
+        {
+            if (array_key_exists($mKey, $aArray2))
+            {
+                if (is_array($mValue))
+                {
+                      $aRecursiveDiff = $this->arrayRecursiveDiff($mValue, $aArray2[$mKey]);
+                      if (count($aRecursiveDiff))
+                      {
+                          $aReturn[$mKey] = $aRecursiveDiff;
+                      }
+                }
+                else
+                {
+                    if ($mValue != $aArray2[$mKey])
+                    {
+                        $aReturn[$mKey] = $mValue;
+                    }
+                }
+            }
+            else
+            {
+                $aReturn[$mKey] = $mValue;
+            }
+        }
+        return $aReturn;
+    }
     
     private function commonProcessTestSuccess( $args, $res )
     {
         $this->input->process( $args );
         $values = $this->input->getOptionValues();
-        $this->assertTrue( count( array_diff( $res, $values ) ) == 0, 'Parameters processed incorrectly.' );
+        $this->assertTrue( count( $this->arrayRecursiveDiff( $res, $values ) ) == 0, 'Parameters processed incorrectly.' );
     }
     
     private function commonProcessTestFailure( $args, $exceptionClass, $message = null )
