Project

General

Profile

Bug #20542 » 11239_02_div_testcase.diff

Administrator Admin, 2009-12-27 22:01

View differences:

tests/t3lib/t3lib_div_testcase.php (working copy)
}
//////////////////////////////////////
// Tests concerning arrayDiffRecursive
//////////////////////////////////////
/**
* Test if a one dimensional array is correctly diffed.
*
* @test
* @see t3lib_div::arrayDiffRecursive
*/
public function doesArrayDiffRecursiveCorrectlyHandleOneDimensionalArrays() {
$array1 = array(
'key1' => 'value1',
'key2' => 'value2',
'key3' => 'value3',
);
$array2 = array(
'key1' => 'value1',
'key3' => 'value3',
);
$expectedResult = array(
'key2' => 'value2',
);
$actualResult = t3lib_div::arrayDiffRecursive($array1, $array2);
$this->assertEquals($expectedResult, $actualResult);
}
/**
* Test if a three dimensional array is correctly diffed.
*
* @test
* @see t3lib_div::arrayDiffRecursive
*/
public function doesArrayDiffRecursiveCorrectlyHandleMultiDimensionalArrays() {
$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::arrayDiffRecursive($array1, $array2);
$this->assertEquals($expectedResult, $actualResult);
}
/**
* Test if arrays are correctly diffed if types are different.
*
* @test
* @see t3lib_div::arrayDiffRecursive
*/
public function doesArrayDiffRecursiveCorrectlyHandleMixedArrays() {
$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::arrayDiffRecursive($array1, $array2);
$this->assertEquals($expectedResult, $actualResult);
}
//////////////////////////////////////
// Tests concerning removeDotsFromTS
//////////////////////////////////////
(5-5/11)