示例#1
0
    /**
     * @expectedException \Magento\Framework\Exception\NotFoundException
     */
    public function testBeforeExecute()
    {
        $actionFlag = $this->getMock('Magento\Framework\App\ActionFlag', [], [], '', false);
        $indexController = $this->getMock('Magento\Wishlist\Controller\Index\Index', [], [], '', false);

        $actionFlag
            ->expects($this->once())
            ->method('set')
            ->with('', 'no-dispatch', true)
            ->willReturn(true);

        $indexController
            ->expects($this->once())
            ->method('getActionFlag')
            ->willReturn($actionFlag);

        $this->authenticationState
            ->expects($this->once())
            ->method('isEnabled')
            ->willReturn(true);

        $this->customerSession
            ->expects($this->once())
            ->method('authenticate')
            ->willReturn(false);

        $this->redirector
            ->expects($this->once())
            ->method('getRefererUrl')
            ->willReturn('http://referer-url.com');

        $this->request
            ->expects($this->once())
            ->method('getParams')
            ->willReturn(['product' => 1]);

        $this->customerSession
            ->expects($this->at(1))
            ->method('__call')
            ->with('getBeforeWishlistUrl', [])
            ->willReturn(false);
        $this->customerSession
            ->expects($this->at(2))
            ->method('__call')
            ->with('setBeforeWishlistUrl', ['http://referer-url.com'])
            ->willReturn(false);
        $this->customerSession
            ->expects($this->at(3))
            ->method('__call')
            ->with('setBeforeWishlistRequest', [['product' => 1]])
            ->willReturn(true);

        $this->config
            ->expects($this->once())
            ->method('isSetFlag')
            ->with('wishlist/general/active')
            ->willReturn(false);

        $this->getPlugin()->beforeExecute($indexController, $this->request);
    }
示例#2
0
 /**
  * @expectedException \Magento\Framework\Exception\NotFoundException
  */
 public function testBeforeDispatch()
 {
     $refererUrl = 'http://referer-url.com';
     $params = ['product' => 1];
     $actionFlag = $this->getMock('Magento\\Framework\\App\\ActionFlag', [], [], '', false);
     $indexController = $this->getMock('Magento\\Wishlist\\Controller\\Index\\Index', [], [], '', false);
     $actionFlag->expects($this->once())->method('set')->with('', 'no-dispatch', true)->willReturn(true);
     $indexController->expects($this->once())->method('getActionFlag')->willReturn($actionFlag);
     $this->authenticationState->expects($this->once())->method('isEnabled')->willReturn(true);
     $this->redirector->expects($this->once())->method('getRefererUrl')->willReturn($refererUrl);
     $this->request->expects($this->once())->method('getParams')->willReturn($params);
     $this->customerSession->expects($this->once())->method('authenticate')->willReturn(false);
     $this->customerSession->expects($this->once())->method('getBeforeWishlistUrl')->willReturn(false);
     $this->customerSession->expects($this->once())->method('setBeforeWishlistUrl')->with($refererUrl)->willReturnSelf();
     $this->customerSession->expects($this->once())->method('setBeforeWishlistRequest')->with($params)->willReturnSelf();
     $this->customerSession->expects($this->once())->method('getBeforeWishlistRequest')->willReturn($params);
     $this->customerSession->expects($this->once())->method('setBeforeRequestParams')->with($params)->willReturnSelf();
     $this->customerSession->expects($this->once())->method('setBeforeModuleName')->with('wishlist')->willReturnSelf();
     $this->customerSession->expects($this->once())->method('setBeforeControllerName')->with('index')->willReturnSelf();
     $this->customerSession->expects($this->once())->method('setBeforeAction')->with('add')->willReturnSelf();
     $this->config->expects($this->once())->method('isSetFlag')->with('wishlist/general/active')->willReturn(false);
     $this->getPlugin()->beforeDispatch($indexController, $this->request);
 }