/** * 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); }
/** * {@inheritdoc} */ public function getFirstSection() { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getFirstSection'); if (!$pluginInfo) { return parent::getFirstSection(); } else { return $this->___callPlugins('getFirstSection', func_get_args(), $pluginInfo); } }
public function testGetFirstSectionReturnsFirstAllowedSection() { $tabMock = $this->getMock('Magento\\Config\\Model\\Config\\Structure\\Element\\Tab', ['current', 'getChildren', 'rewind'], [], '', 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()); }