public function testExecuteWithException() { $addressId = 1; $customerId = 2; $this->resultRedirectFactory->expects($this->once())->method('create')->willReturn($this->resultRedirect); $this->request->expects($this->once())->method('getParam')->with('id', false)->willReturn($addressId); $this->validatorMock->expects($this->once())->method('validate')->with($this->request)->willReturn(true); $this->addressRepositoryMock->expects($this->once())->method('getById')->with($addressId)->willReturn($this->address); $this->sessionMock->expects($this->once())->method('getCustomerId')->willReturn($customerId); $this->address->expects($this->once())->method('getCustomerId')->willReturn(34); $exception = new \Exception('Exception'); $this->messageManager->expects($this->once())->method('addError')->with(__('We can\'t delete the address right now.'))->willThrowException($exception); $this->messageManager->expects($this->once())->method('addException')->with($exception, __('We can\'t delete the address right now.')); $this->resultRedirect->expects($this->once())->method('setPath')->with('*/*/index')->willReturnSelf(); $this->assertSame($this->resultRedirect, $this->model->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); } }