public function testTransform() { $config = array('tab_1' => array('sort_order' => array('#text' => 10), 'frontend_type' => array('#text' => 'text'), 'class' => array('#text' => 'css class'), 'label' => array('#text' => 'tab label'), 'comment' => array('#cdata-section' => 'tab comment')), 'tab_2' => array()); $expected = array(array('nodeName' => 'tab', '@attributes' => array('id' => 'tab_1', 'sortOrder' => 10, 'type' => 'text', 'class' => 'css class'), 'parameters' => array(array('name' => 'label', '#text' => 'tab label'), array('name' => 'comment', '#cdata-section' => 'tab comment'))), array('nodeName' => 'tab', '@attributes' => array('id' => 'tab_2'), 'parameters' => array())); $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; }