public function entity_bundle_plugin_merge::testMerge in Entity bundle plugin 7
File
- tests/
entity_bundle_plugin_merge.test, line 22
Class
- entity_bundle_plugin_merge
- @author marand
Code
public function testMerge() {
$a = array(
'test_1' => array(
'X',
'Y',
),
'test_2' => array(
0 => 'A',
1 => 'B',
),
);
$b = array(
'test_1' => array(
'X',
),
'test_2' => array(
0 => 'C',
1 => 'D',
),
);
// Drupal core behavior.
$expected = array(
'test_1' => array(
'X',
'Y',
'X',
),
'test_2' => array(
0 => 'A',
1 => 'B',
2 => 'C',
3 => 'D',
),
);
$actual = drupal_array_merge_deep_array(array(
$a,
$b,
));
$this
->assertEqual($expected, $actual, 'drupal_array_merge_deep() creates new numeric keys');
$expected = array(
'test_1' => array(
'X',
'Y',
),
'test_2' => array(
0 => 'C',
1 => 'D',
),
);
$actual = _entity_bundle_plugin_array_merge_deep_array(array(
$a,
$b,
));
$this
->assertEqual($expected, $actual, 'EBP merge replaces non-array values on numeric keys.');
}