/** * Check if current section is found and is allowed * * @param \Magento\Framework\App\RequestInterface $request * @return \Magento\Framework\App\ResponseInterface */ public function dispatch(\Magento\Framework\App\RequestInterface $request) { if (!$request->getParam('section')) { $request->setParam('section', $this->_configStructure->getFirstSection()->getId()); } return parent::dispatch($request); }
/** * Check if current section is found and is allowed * * @param \Magento\Framework\App\RequestInterface $request * @return \Magento\Framework\App\ResponseInterface */ public function dispatch(\Magento\Framework\App\RequestInterface $request) { $section = null; if (!$request->getParam('section')) { $section = $this->_configStructure->getFirstSection(); $request->setParam('section', $section->getId()); } else { $this->_isSectionAllowed($request->getParam('section')); } return parent::dispatch($request); }
public function testGetFirstSectionReturnsFirstAllowedSection() { $tabMock = $this->getMock('Magento\\Backend\\Model\\Config\\Structure\\Element\\Tab', array('current', 'getChildren', 'rewind'), array(), '', false); $tabMock->expects($this->any())->method('getChildren')->will($this->returnSelf()); $tabMock->expects($this->once())->method('rewind'); $tabMock->expects($this->once())->method('current')->will($this->returnValue('currentSection')); $this->_tabIteratorMock->expects($this->once())->method('rewind'); $this->_tabIteratorMock->expects($this->once())->method('current')->will($this->returnValue($tabMock)); $this->assertEquals('currentSection', $this->_model->getFirstSection()); }