/** * {@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); } }
public function testExecuteException() { $addressId = 1; $postValue = 'post_value'; $url = 'result_url'; $this->formKeyValidator->expects($this->once())->method('validate')->with($this->request)->willReturn(true); $this->request->expects($this->once())->method('isPost')->willReturn(true); $this->request->expects($this->once())->method('getParam')->with('id')->willReturn($addressId); $this->request->expects($this->never())->method('getPostValue')->willReturn($postValue); $exception = new \Exception(__('Exception')); $this->addressRepository->expects($this->once())->method('getById')->with($addressId)->willThrowException($exception); $this->messageManager->expects($this->once())->method('addException')->with($exception, __('We can\'t save the address.'))->willReturnSelf(); $this->session->expects($this->never())->method('setAddressFormData')->with($postValue)->willReturnSelf(); $urlBuilder = $this->getMockBuilder('Magento\\Framework\\UrlInterface')->getMockForAbstractClass(); $urlBuilder->expects($this->once())->method('getUrl')->with('*/*/index')->willReturn($url); $this->objectManager->expects($this->once())->method('create')->with('Magento\\Framework\\UrlInterface')->willReturn($urlBuilder); $this->redirect->expects($this->once())->method('error')->with($url)->willReturn($url); $this->resultRedirect->expects($this->once())->method('setUrl')->with($url)->willReturnSelf(); $this->assertEquals($this->resultRedirect, $this->model->execute()); }
/** * @param \Magento\Framework\App\Action\Context $context * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator * @param \Magento\Customer\Model\Metadata\FormFactory $formFactory * @param \Magento\Customer\Api\AddressRepositoryInterface $addressRepository * @param \Magento\Customer\Api\Data\AddressInterfaceFactory $addressDataFactory * @param \Magento\Customer\Api\Data\RegionInterfaceFactory $regionDataFactory * @param \Magento\Framework\Reflection\DataObjectProcessor $dataProcessor * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper * @param \Magento\Framework\Controller\Result\RedirectFactory $resultRedirectFactory * @param \Magento\Framework\Controller\Result\ForwardFactory $resultForwardFactory * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory * @param AddressSession * @param ValidationResultInterfaceFactory * @param AddressConverter * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct(\Magento\Framework\App\Action\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator, \Magento\Customer\Model\Metadata\FormFactory $formFactory, \Magento\Customer\Api\AddressRepositoryInterface $addressRepository, \Magento\Customer\Api\Data\AddressInterfaceFactory $addressDataFactory, \Magento\Customer\Api\Data\RegionInterfaceFactory $regionDataFactory, \Magento\Framework\Reflection\DataObjectProcessor $dataProcessor, \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, \Magento\Framework\Controller\Result\ForwardFactory $resultForwardFactory, \Magento\Framework\View\Result\PageFactory $resultPageFactory, AddressSession $addressSession) { parent::__construct($context, $customerSession, $formKeyValidator, $formFactory, $addressRepository, $addressDataFactory, $regionDataFactory, $dataProcessor, $dataObjectHelper, $resultForwardFactory, $resultPageFactory); $this->addressSession = $addressSession; }