Exemplo n.º 1
0
 /**
  * {@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 testExecuteEmptyQuoteError()
 {
     $resultExpectation = ['success' => false, 'error' => true, 'error_messages' => __('Your payment has been declined. Please try again.')];
     $quoteMock = null;
     $jsonMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Json')->disableOriginalConstructor()->getMock();
     $this->sessionManagerMock->expects($this->atLeastOnce())->method('getQuote')->willReturn($quoteMock);
     $this->resultJsonFactoryMock->expects($this->once())->method('create')->willReturn($jsonMock);
     $jsonMock->expects($this->once())->method('setData')->with($resultExpectation)->willReturnSelf();
     $this->assertEquals($jsonMock, $this->controller->execute());
 }
Exemplo n.º 3
0
 /**
  * Run test execute method
  *
  * @param array $result
  * @param array $resultExpectation
  *
  * @dataProvider executeDataProvider
  */
 public function testExecute(array $result, array $resultExpectation)
 {
     $quoteId = 99;
     $quoteMock = $this->getMockBuilder('Magento\\Quote\\Model\\Quote')->disableOriginalConstructor()->getMock();
     $tokenMock = $this->getMockBuilder('Magento\\Framework\\Object')->setMethods(['getData', 'getSecuretoken'])->disableOriginalConstructor()->getMock();
     $jsonMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Json')->disableOriginalConstructor()->getMock();
     $this->transparentMock->expects($this->once())->method('getCode')->willReturn('transparent');
     $this->sessionManagerMock->expects($this->atLeastOnce())->method('getQuote')->willReturn($quoteMock);
     $quoteMock->expects($this->once())->method('getId')->willReturn($quoteId);
     $this->sessionTransparentMock->expects($this->once())->method('setQuoteId')->with($quoteId);
     $this->secureTokenServiceMock->expects($this->once())->method('requestToken')->with($quoteMock)->willReturn($tokenMock);
     $this->transparentMock->expects($this->once())->method('getCode')->willReturn('transparent');
     $tokenMock->expects($this->once())->method('getData')->willReturn($result['transparent']['fields']);
     $tokenMock->expects($this->once())->method('getSecuretoken')->willReturn($result['success']);
     $this->resultJsonFactoryMock->expects($this->once())->method('create')->willReturn($jsonMock);
     $jsonMock->expects($this->once())->method('setData')->with($resultExpectation)->willReturnSelf();
     $this->assertEquals($jsonMock, $this->controller->execute());
 }