예제 #1
0
 public function testGetTabsBuildsSectionTree()
 {
     $this->_structureDataMock = $this->getMock('Magento\\Backend\\Model\\Config\\Structure\\Data', array(), array(), '', false);
     $this->_structureDataMock->expects($this->any())->method('get')->will($this->returnValue(array('sections' => array('section1' => array('tab' => 'tab1')), 'tabs' => array('tab1' => array()))));
     $expected = array('tab1' => array('children' => array('section1' => array('tab' => 'tab1'))));
     $model = new \Magento\Backend\Model\Config\Structure($this->_structureDataMock, $this->_tabIteratorMock, $this->_flyweightFactory, $this->_scopeDefinerMock);
     $this->_tabIteratorMock->expects($this->once())->method('setElements')->with($expected);
     $this->assertEquals($this->_tabIteratorMock, $model->getTabs());
 }
예제 #2
0
 public function testGetElementByPathPartsIfSectionDataIsEmpty()
 {
     $elementMock = $this->getMock('Magento\\Backend\\Model\\Config\\Structure\\Element\\Field', [], [], '', false);
     $fieldData = ['id' => 'field_3', 'path' => 'section_1/group_level_1', '_elementType' => 'field'];
     $elementMock->expects($this->once())->method('setData')->with($fieldData, 'scope');
     $this->_flyweightFactory->expects($this->once())->method('create')->with('field')->will($this->returnValue($elementMock));
     $structureDataMock = $this->getMock('Magento\\Backend\\Model\\Config\\Structure\\Data', [], [], '', false);
     $structureDataMock->expects($this->once())->method('get')->will($this->returnValue([]));
     $structureMock = new \Magento\Backend\Model\Config\Structure($structureDataMock, $this->_tabIteratorMock, $this->_flyweightFactory, $this->_scopeDefinerMock);
     $pathParts = explode('/', 'section_1/group_level_1/field_3');
     $this->assertEquals($elementMock, $structureMock->getElementByPathParts($pathParts));
 }