Ejemplo n.º 1
0
 public function prepare()
 {
     $this->contextMock = $this->getMock('Magento\\Framework\\View\\Element\\Template\\Context', [], [], '', false);
     $this->checkoutSessionMock = $this->getMock('Magento\\Checkout\\Model\\Session', [], [], '', false);
     $this->orderFactoryMock = $this->getMock('Magento\\Sales\\Model\\OrderFactory', ['getQuote'], [], '', false);
     $this->hssHelperMock = $this->getMock('Magento\\Paypal\\Helper\\Hss', [], [], '', false);
     $this->paymentDataMock = $this->getMock('Magento\\Payment\\Helper\\Data', [], [], '', false);
     $this->quoteMock = $this->getMock('Magento\\Quote\\Model\\Quote', ['getPayment', '__wakeup'], [], '', false);
     $this->paymentMock = $this->getMock('Magento\\Quote\\Model\\Quote\\Payment', [], [], '', false);
     $this->checkoutSessionMock->expects($this->any())->method('getQuote')->will($this->returnValue($this->quoteMock));
     $this->quoteMock->expects($this->any())->method('getPayment')->will($this->returnValue($this->paymentMock));
     $this->hssHelperMock->expects($this->any())->method('getHssMethods')->will($this->returnValue([]));
 }
 /**
  * Run setResponseAfterSaveOrder method test
  *
  * @return void
  */
 public function testSetResponseAfterSaveOrderSuccess()
 {
     $testData = $this->getSetResponseAfterSaveOrderTestData();
     $observerMock = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->getMock();
     $orderMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->getMock();
     $paymentMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Payment')->disableOriginalConstructor()->getMock();
     $resultMock = $this->getMockBuilder('Magento\\Framework\\DataObject')->disableOriginalConstructor()->getMock();
     $layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\LayoutInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $blockMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\BlockInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->coreRegistryMock->expects($this->once())->method('registry')->with('hss_order')->willReturn($orderMock);
     $orderMock->expects($this->once())->method('getId')->willReturn($testData['order.getId']);
     $orderMock->expects($this->once())->method('getPayment')->willReturn($paymentMock);
     $paymentMock->expects($this->once())->method('getMethod')->willReturn($testData['payment.getMethod']);
     $this->paypalHssMock->expects($this->once())->method('getHssMethods')->willReturn($testData['paypalHss.getHssMethods']);
     $observerMock->expects($this->atLeastOnce())->method('getData')->with('result')->willReturn($resultMock);
     $resultMock->expects($this->once())->method('getData')->willReturn($testData['result.getData']);
     $this->viewMock->expects($this->once())->method('loadLayout')->with('checkout_onepage_review', true, true, false);
     $this->viewMock->expects($this->once())->method('getLayout')->willReturn($layoutMock);
     $layoutMock->expects($this->once())->method('getBlock')->with('paypal.iframe')->willReturn($blockMock);
     $blockMock->expects($this->once())->method('toHtml')->willReturn($testData['block.toHtml']);
     $resultMock->expects($this->once())->method('setData')->with($testData['result.setData']);
     $this->_model->execute($observerMock);
 }