Beispiel #1
0
 public function testGetSuccessOrderUrl()
 {
     $order = $this->getMock('Magento\\Sales\\Model\\Order', array('loadByIncrementId', 'getId', '__wakeup'), array(), '', false);
     $order->expects($this->once())->method('loadByIncrementId')->with('invoice number')->will($this->returnSelf());
     $order->expects($this->once())->method('getId')->will($this->returnValue('order id'));
     $this->_orderFactory->expects($this->once())->method('create')->will($this->returnValue($order));
     $this->_urlBuilder->expects($this->once())->method('getUrl')->with($this->equalTo('sales/order/view'), $this->equalTo(array('order_id' => 'order id')))->will($this->returnValue('some value'));
     $this->assertEquals('some value', $this->_model->getSuccessOrderUrl(array('x_invoice_num' => 'invoice number', 'some param')));
 }
Beispiel #2
0
 public function testGetSuccessOrderUrl()
 {
     $orderMock = $this->getMock('Magento\\Sales\\Model\\Order', ['loadByIncrementId', 'getId', '__wakeup'], [], '', false);
     $orderMock->expects($this->once())->method('loadByIncrementId')->with('invoice number')->willReturnSelf();
     $orderMock->expects($this->once())->method('getId')->willReturn('order id');
     $this->orderFactoryMock->expects($this->once())->method('create')->willReturn($orderMock);
     $this->urlBuilderMock->expects($this->once())->method('getUrl')->with('sales/order/view', ['order_id' => 'order id'])->willReturn('some value');
     $this->assertEquals('some value', $this->dataHelper->getSuccessOrderUrl(['x_invoice_num' => 'invoice number', 'some param']));
 }
Beispiel #3
0
 public function setUp()
 {
     $objectManager = new ObjectManager($this);
     $this->order = $this->getMockBuilder('\\Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->setMethods(['load', '__wakeup'])->getMock();
     $this->orderFactory = $this->getMockBuilder('\\Magento\\Sales\\Model\\OrderFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->orderFactory->expects($this->once())->method('create')->will($this->returnValue($this->order));
     $this->orderItemTaxResource = $this->getMockBuilder('\\Magento\\Tax\\Model\\Resource\\Sales\\Order\\Tax\\Item')->disableOriginalConstructor()->setMethods(['getTaxItemsByOrderId', '__wakeup'])->getMock();
     $orderItemTaxFactory = $this->getMockBuilder('\\Magento\\Tax\\Model\\Resource\\Sales\\Order\\Tax\\ItemFactory')->disableOriginalConstructor()->setMethods(['create', '__wakeup'])->getMock();
     $orderItemTaxFactory->expects($this->once())->method('create')->will($this->returnValue($this->orderItemTaxResource));
     $this->ordertTaxService = $objectManager->getObject('Magento\\Tax\\Service\\V1\\OrderTaxService', ['orderFactory' => $this->orderFactory, 'orderItemTaxFactory' => $orderItemTaxFactory]);
 }
Beispiel #4
0
 private function initOrderMock($orderId, $state)
 {
     $this->orderFactoryMock->expects($this->any())->method('create')->will($this->returnValue($this->orderMock));
     $this->orderMock->expects($this->once())->method('loadByIncrementId')->with($orderId)->will($this->returnSelf());
     $this->orderMock->expects($this->once())->method('getIncrementId')->will($this->returnValue($orderId));
     $this->orderMock->expects($this->once())->method('getState')->will($this->returnValue($state));
 }
 /**
  * @param $state
  * @param $restoreQuote
  * @param $expectedGotoSection
  * @dataProvider testNotAllowedOrderStateDataProvider
  */
 public function testExecuteNotAllowedOrderState($state, $restoreQuote, $expectedGotoSection)
 {
     $lastRealOrderId = '000000001';
     $this->viewMock->expects($this->once())->method('getLayout')->will($this->returnValue($this->layoutMock));
     $this->layoutMock->expects($this->once())->method('getBlock')->will($this->returnValue($this->blockMock));
     $this->checkoutSessionMock->expects($this->any())->method('getLastRealOrderId')->will($this->returnValue($lastRealOrderId));
     $this->checkoutSessionMock->expects($this->any())->method('getLastRealOrder')->will($this->returnValue($this->orderMock));
     $this->checkoutSessionMock->expects($this->any())->method('restoreQuote')->will($this->returnValue($restoreQuote));
     $this->orderFactoryMock->expects($this->any())->method('create')->will($this->returnValue($this->orderMock));
     $this->orderMock->expects($this->once())->method('loadByIncrementId')->with($lastRealOrderId)->will($this->returnSelf());
     $this->orderMock->expects($this->once())->method('getIncrementId')->will($this->returnValue($lastRealOrderId));
     $this->orderMock->expects($this->once())->method('getState')->will($this->returnValue($state));
     $this->blockMock->expects($this->at(0))->method('setData')->with('goto_section', $expectedGotoSection)->will($this->returnSelf());
     $this->blockMock->expects($this->at(1))->method('setData')->with('error_msg', __('Your payment has been declined. Please try again.'))->will($this->returnSelf());
     $this->returnUrl->execute();
 }