/**
  * {@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 testExecuteSuccessWithUseStoreInUrl()
 {
     $currentActiveStoreCode = 'sv1';
     $storeToSwitchToCode = 'sv2';
     $defaultStoreViewCode = 'default';
     $originalRedirectUrl = "magento.com/{$currentActiveStoreCode}/test-page/test-sub-page";
     $expectedRedirectUrl = "magento.com/{$storeToSwitchToCode}/test-page/test-sub-page";
     $currentActiveStoreMock = $this->getMockBuilder('Magento\\Store\\Api\\Data\\StoreInterface')->disableOriginalConstructor()->setMethods(['isUseStoreInUrl', 'getBaseUrl'])->getMockForAbstractClass();
     $defaultStoreViewMock = $this->getMockBuilder('Magento\\Store\\Api\\Data\\StoreInterface')->getMock();
     $storeToSwitchToMock = $this->getMockBuilder('Magento\\Store\\Api\\Data\\StoreInterface')->disableOriginalConstructor()->setMethods(['isUseStoreInUrl', 'getBaseUrl'])->getMockForAbstractClass();
     $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($currentActiveStoreMock);
     $this->requestMock->expects($this->once())->method('getParam')->willReturn($storeToSwitchToCode);
     $this->storeRepositoryMock->expects($this->once())->method('getActiveStoreByCode')->willReturn($storeToSwitchToMock);
     $this->storeManagerMock->expects($this->once())->method('getDefaultStoreView')->willReturn($defaultStoreViewMock);
     $defaultStoreViewMock->expects($this->once())->method('getId')->willReturn($defaultStoreViewCode);
     $storeToSwitchToMock->expects($this->once())->method('getId')->willReturn($storeToSwitchToCode);
     $storeToSwitchToMock->expects($this->once())->method('isUseStoreInUrl')->willReturn(true);
     $this->redirectMock->expects($this->any())->method('getRedirectUrl')->willReturn($originalRedirectUrl);
     $currentActiveStoreMock->expects($this->any())->method('getBaseUrl')->willReturn("magento.com/{$currentActiveStoreCode}");
     $storeToSwitchToMock->expects($this->once())->method('getBaseUrl')->willReturn("magento.com/{$storeToSwitchToCode}");
     $this->responseMock->expects($this->once())->method('setRedirect')->with($expectedRedirectUrl);
     $this->model->execute();
 }
Beispiel #3
0
 public function testExecute()
 {
     $this->redirect->expects($this->once())->method('getRedirectUrl')->willReturn('url-redirect');
     $this->response->expects($this->once())->method('setRedirect')->with('url-redirect');
     $this->unit->execute();
 }