|
|
@@ -44,6 +44,15 @@ class Child extends Base {
|
|
|
'Orange'
|
|
|
];
|
|
|
|
|
|
+ public $nestedProperty = [
|
|
|
+ 'Red' => [
|
|
|
+ 'apple' => 'gala',
|
|
|
+ ],
|
|
|
+ 'Green' => [
|
|
|
+ 'citrus' => 'lime'
|
|
|
+ ],
|
|
|
+ ];
|
|
|
+
|
|
|
}
|
|
|
|
|
|
class Grandchild extends Child {
|
|
|
@@ -54,6 +63,16 @@ class Grandchild extends Child {
|
|
|
'Green' => ['apple'],
|
|
|
'Yellow' => ['banana']
|
|
|
];
|
|
|
+
|
|
|
+ public $nestedProperty = [
|
|
|
+ 'Red' => [
|
|
|
+ 'apple' => 'mcintosh',
|
|
|
+ 'citrus' => 'blood orange',
|
|
|
+ ],
|
|
|
+ 'Green' => [
|
|
|
+ 'citrus' => 'key lime'
|
|
|
+ ],
|
|
|
+ ];
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -76,7 +95,7 @@ class MergeVariablesTraitTest extends TestCase {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Test merging vars as an assoc list.
|
|
|
+ * Test merging vars as an associative list.
|
|
|
*
|
|
|
* @return void
|
|
|
*/
|
|
|
@@ -93,7 +112,31 @@ class MergeVariablesTraitTest extends TestCase {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Test merging variable in associated properties that contain
|
|
|
+ * additional keys.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testMergeVarsAsAssocWithKeyValues() {
|
|
|
+ $object = new Grandchild();
|
|
|
+ $object->mergeVars(['nestedProperty'], ['associative' => ['nestedProperty']]);
|
|
|
+
|
|
|
+ $expected = [
|
|
|
+ 'Red' => [
|
|
|
+ 'apple' => 'mcintosh',
|
|
|
+ 'citrus' => 'blood orange',
|
|
|
+ ],
|
|
|
+ 'Green' => [
|
|
|
+ 'citrus' => 'key lime',
|
|
|
+ ],
|
|
|
+ ];
|
|
|
+ $this->assertEquals($expected, $object->nestedProperty);
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
* Test merging vars with mixed modes.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
*/
|
|
|
public function testMergeVarsMixedModes() {
|
|
|
$object = new Grandchild();
|