$node =
new ArrayNode('root'
);
$mappingsNode =
new PrototypedArrayNode('mappings'
);
$node->
addChild($mappingsNode);
// each item under mappings is just a scalar
$prototype =
new ScalarNode(null,
$mappingsNode);
$mappingsNode->
setPrototype($prototype);
$remappings =
[];
$remappings[] =
['mapping', 'mappings'
];
$node->
setXmlRemappings($remappings);
$normalized =
$node->
normalize(['mapping' =>
['foo', 'bar'
]]);
$this->
assertEquals(['mappings' =>
['foo', 'bar'
]],
$normalized);
} /**
* Tests that when a key attribute is mapped, that key is removed from the array.
*
* <things>
* <option id="option1" value="foo">
* <option id="option2" value="bar">
* </things>
*
* The above should finally be mapped to an array that looks like this
* (because "id" is the key attribute).
*
* [
* 'things' => [
* 'option1' => 'foo',
* 'option2' => 'bar',
* ]
* ]
*/