public function testTransform() { $config = ['section_1' => ['sort_order' => ['#text' => 10], 'frontend_type' => ['#text' => 'text'], 'class' => ['#text' => 'css class'], 'label' => ['#text' => 'section label'], 'comment' => ['#cdata-section' => 'section comment'], 'resource' => ['#text' => 'acl'], 'header_css' => ['#text' => 'some css class'], 'tab' => ['#text' => 'some tab']], 'section_2' => [], 'section_3' => ['groups' => ['label' => 'label']]]; $expected = [['nodeName' => 'section', '@attributes' => ['id' => 'section_1', 'sortOrder' => 10, 'type' => 'text'], 'parameters' => [['name' => 'class', '#text' => 'css class'], ['name' => 'label', '#text' => 'section label'], ['name' => 'comment', '#cdata-section' => 'section comment'], ['name' => 'resource', '#text' => 'acl'], ['name' => 'header_css', '#text' => 'some css class'], ['name' => 'tab', '#text' => 'some tab']]], ['nodeName' => 'section', '@attributes' => ['id' => 'section_2'], 'parameters' => []], ['nodeName' => 'section', '@attributes' => ['id' => 'section_3'], 'parameters' => [], 'subConfig' => ['label' => 'label']]]; $this->_groupMapperMock->expects($this->once())->method('transform')->with(['label' => 'label'])->will($this->returnArgument(0)); $actual = $this->_object->transform($config); $this->assertEquals($expected, $actual); }
/** * Transform configuration * * @param array $config * @return array */ public function transform(array $config) { $output = array(); $output['comment'] = $config['comment']; $tabsConfig = isset($config['tabs']) ? $config['tabs'] : array(); $sectionsConfig = isset($config['sections']) ? $config['sections'] : array(); /** @var array $nodes */ $nodes = $this->_tabMapper->transform($tabsConfig); $transformedSections = $this->_sectionMapper->transform($sectionsConfig); $nodes = array_merge($nodes, $transformedSections); $output['nodes'] = $nodes; return $output; }