/** * Run test execute method * * @param int|bool $categoryId * @param int $storeId * @return void * * @dataProvider dataProviderExecute * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function testExecute($categoryId, $storeId) { $rootCategoryId = 2; $this->requestMock->expects($this->atLeastOnce())->method('getParam')->will($this->returnValueMap([['id', false, $categoryId], ['store', null, $storeId]])); $this->requestMock->expects($this->atLeastOnce())->method('getQuery')->with('isAjax')->will($this->returnValue(false)); $this->mockInitCategoryCall(); $this->sessionMock->expects($this->once())->method('__call')->will($this->returnValue([])); if (!$categoryId) { if ($storeId) { $this->storeManagerInterfaceMock->expects($this->once())->method('getStore')->with($storeId)->will($this->returnSelf()); } else { $this->storeManagerInterfaceMock->expects($this->once())->method('getDefaultStoreView')->will($this->returnSelf()); } $this->storeManagerInterfaceMock->expects($this->once())->method('getRootCategoryId')->will($this->returnValue($rootCategoryId)); $categoryId = $rootCategoryId; } $this->requestMock->expects($this->atLeastOnce())->method('setParam')->with('id', $categoryId)->will($this->returnValue(true)); $this->categoryMock->expects($this->atLeastOnce())->method('getId')->will($this->returnValue($categoryId)); /** * @var \Magento\Framework\View\Element\Template * |\PHPUnit_Framework_MockObject_MockObject $blockMock */ $blockMock = $this->getMock('Magento\\Framework\\View\\Element\\Template', ['setStoreId'], [], '', false); $blockMock->expects($this->once())->method('setStoreId')->with($storeId); $this->resultPageMock->expects($this->once())->method('getLayout')->will($this->returnSelf()); $this->resultPageMock->expects($this->once())->method('getBlock')->willReturn($blockMock); $this->edit->execute(); }
/** * {@inheritdoc} */ public function dispatch(\Magento\Framework\App\RequestInterface $request) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'dispatch'); if (!$pluginInfo) { return parent::dispatch($request); } else { return $this->___callPlugins('dispatch', func_get_args(), $pluginInfo); } }
/** * {@inheritdoc} */ public function getResponse() { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getResponse'); if (!$pluginInfo) { return parent::getResponse(); } else { return $this->___callPlugins('getResponse', func_get_args(), $pluginInfo); } }