public function testTransform() { $config = array('section_1' => array('sort_order' => array('#text' => 10), 'frontend_type' => array('#text' => 'text'), 'class' => array('#text' => 'css class'), 'label' => array('#text' => 'section label'), 'comment' => array('#cdata-section' => 'section comment'), 'resource' => array('#text' => 'acl'), 'header_css' => array('#text' => 'some css class'), 'tab' => array('#text' => 'some tab')), 'section_2' => array(), 'section_3' => array('groups' => array('label' => 'label'))); $expected = array(array('nodeName' => 'section', '@attributes' => array('id' => 'section_1', 'sortOrder' => 10, 'type' => 'text'), 'parameters' => array(array('name' => 'class', '#text' => 'css class'), array('name' => 'label', '#text' => 'section label'), array('name' => 'comment', '#cdata-section' => 'section comment'), array('name' => 'resource', '#text' => 'acl'), array('name' => 'header_css', '#text' => 'some css class'), array('name' => 'tab', '#text' => 'some tab'))), array('nodeName' => 'section', '@attributes' => array('id' => 'section_2'), 'parameters' => array()), array('nodeName' => 'section', '@attributes' => array('id' => 'section_3'), 'parameters' => array(), 'subConfig' => array('label' => 'label'))); $this->_groupMapperMock->expects($this->once())->method('transform')->with(array('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; }