Follow-up to bug #11239: Added testcase for t3lib_div::arrayDiffAssocRecursive()
authorChristian Kuhn <lolli@schwarzbu.ch>
Wed, 24 Mar 2010 23:18:04 +0000 (23:18 +0000)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 24 Mar 2010 23:18:04 +0000 (23:18 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@7160 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
tests/t3lib/t3lib_div_testcase.php

index 17a350f..8c396fb 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 2010-03-25  Christian Kuhn  <lolli@schwarzbu.ch>
 
+       * Follow-up to bug #11239: Added testcase for t3lib_div::arrayDiffAssocRecursive()
        * Follow-up to bug #11239: typolink addQueryString.exclude does not support arrays, main patch for tslib_content
        * Fixed bug #11239: typolink addQueryString.exclude does not support arrays, pre-patch to add t3lib_div::arrayDiffAssocRecursive()
        * Added feature #9289: Missing index for deleting outdated session data in fe_session_data
index 3fb0f2e..6e88e28 100644 (file)
@@ -487,6 +487,100 @@ class t3lib_div_testcase extends tx_phpunit_testcase {
        }
 
        //////////////////////////////////////
+       // Tests concerning arrayDiffAssocRecursive
+       //////////////////////////////////////
+
+       /**
+        * Test if a one dimensional array is correctly diffed.
+        *
+        * @test
+        * @see t3lib_div::arrayDiffAssocRecursive
+        */
+       public function doesArrayDiffAssocRecursiveCorrectlyHandleOneDimensionalArrays() {
+               $array1 = array(
+                       'key1' => 'value1',
+                       'key2' => 'value2',
+                       'key3' => 'value3',
+               );
+               $array2 = array(
+                       'key1' => 'value1',
+                       'key3' => 'value3',
+               );
+               $expectedResult = array(
+                       'key2' => 'value2',
+               );
+               $actualResult = t3lib_div::arrayDiffAssocRecursive($array1, $array2);
+               $this->assertEquals($expectedResult, $actualResult);
+       }
+
+       /**
+        * Test if a three dimensional array is correctly diffed.
+        *
+        * @test
+        * @see t3lib_div::arrayDiffAssocRecursive
+        */
+       public function doesArrayDiffAssocRecursiveCorrectlyHandleMultiDimensionalArrays() {
+               $array1 = array(
+                       'key1' => 'value1',
+                       'key2' => array(
+                               'key21' => 'value21',
+                               'key22' => 'value22',
+                               'key23' => array(
+                                       'key231' => 'value231',
+                                       'key232' => 'value232',
+                               ),
+                       ),
+               );
+               $array2 = array(
+                       'key1' => 'value1',
+                       'key2' => array(
+                               'key21' => 'value21',
+                               'key23' => array(
+                                       'key231' => 'value231',
+                               ),
+                       ),
+               );
+               $expectedResult = array(
+                       'key2' => array(
+                               'key22' => 'value22',
+                               'key23' => array(
+                                       'key232' => 'value232',
+                               ),
+                       ),
+               );
+               $actualResult = t3lib_div::arrayDiffAssocRecursive($array1, $array2);
+               $this->assertEquals($expectedResult, $actualResult);
+       }
+
+       /**
+        * Test if arrays are correctly diffed if types are different.
+        *
+        * @test
+        * @see t3lib_div::arrayDiffAssocRecursive
+        */
+       public function doesArrayDiffAssocRecursiveCorrectlyHandleMixedArrays() {
+               $array1 = array(
+                       'key1' => array(
+                               'key11' => 'value11',
+                               'key12' => 'value12',
+                       ),
+                       'key2' => 'value2',
+                       'key3' => 'value3',
+               );
+               $array2 = array(
+                       'key1' => 'value1',
+                       'key2' => array(
+                               'key21' => 'value21',
+                       ),
+               );
+               $expectedResult = array(
+                       'key3' => 'value3',
+               );
+               $actualResult = t3lib_div::arrayDiffAssocRecursive($array1, $array2);
+               $this->assertEquals($expectedResult, $actualResult);
+       }
+
+       //////////////////////////////////////
        // Tests concerning removeDotsFromTS
        //////////////////////////////////////