function RedirectUnitTest::testCompareArrayRecursive in Redirect 7.2
Same name and namespace in other branches
- 7 redirect.test \RedirectUnitTest::testCompareArrayRecursive()
Test the redirect_compare_array_recursive() function.
File
- ./
redirect.test, line 98 - Unit tests for the redirect module.
Class
Code
function testCompareArrayRecursive() {
$haystack = array(
'a' => 'aa',
'b' => 'bb',
'c' => array(
'c1' => 'cc1',
'c2' => 'cc2',
),
);
$cases = array(
array(
'query' => array(
'a' => 'aa',
'b' => 'invalid',
),
'result' => FALSE,
),
array(
'query' => array(
'b' => 'bb',
'b' => 'bb',
),
'result' => TRUE,
),
array(
'query' => array(
'b' => 'bb',
'c' => 'invalid',
),
'result' => FALSE,
),
array(
'query' => array(
'b' => 'bb',
'c' => array(),
),
'result' => TRUE,
),
array(
'query' => array(
'b' => 'bb',
'c' => array(
'invalid',
),
),
'result' => FALSE,
),
array(
'query' => array(
'b' => 'bb',
'c' => array(
'c2' => 'invalid',
),
),
'result' => FALSE,
),
array(
'query' => array(
'b' => 'bb',
'c' => array(
'c2' => 'cc2',
),
),
'result' => TRUE,
),
);
foreach ($cases as $index => $case) {
$this
->assertEqual($case['result'], redirect_compare_array_recursive($case['query'], $haystack));
}
}