Exemple #1
0
 public function testGetShippingAddress()
 {
     /** @var AddressAdapterInterface $addressAdapterMock */
     $addressAdapterMock = $this->getMockBuilder('Magento\\Payment\\Gateway\\Data\\AddressAdapterInterface')->getMockForAbstractClass();
     /** @var \Magento\Sales\Api\Data\OrderAddressInterface $orderAddressMock */
     $orderAddressMock = $this->getMockBuilder('Magento\\Sales\\Api\\Data\\OrderAddressInterface')->getMockForAbstractClass();
     $this->addressAdapterFactoryMock->expects($this->once())->method('create')->with(['address' => $orderAddressMock])->willReturn($addressAdapterMock);
     $this->orderMock->expects($this->once())->method('getShippingAddress')->willReturn($orderAddressMock);
     $this->assertSame($addressAdapterMock, $this->model->getShippingAddress());
 }
 public function testExecuteUpdateAction()
 {
     $orderId = 30;
     $action = 'update';
     $this->requestMock->expects($this->at(0))->method('getParam')->with('order_id')->willReturn($orderId);
     $this->requestMock->expects($this->at(1))->method('getParam')->with('action')->willReturn($action);
     $this->resultRedirectFactoryMock->expects($this->once())->method('create')->willReturn($this->resultRedirectMock);
     $this->orderRepositoryMock->expects($this->once())->method('get')->with($orderId)->willReturn($this->orderMock);
     $this->orderMock->expects($this->any())->method('getEntityId')->willReturn($orderId);
     $this->orderMock->expects($this->any())->method('getPayment')->willReturn($this->paymentMock);
     $this->orderRepositoryMock->expects($this->once())->method('save')->with($this->orderMock)->willReturnSelf();
     $this->paymentMock->expects($this->once())->method('update');
     $this->paymentMock->expects($this->any())->method('getIsTransactionApproved')->willReturn(true);
     $this->messageManagerMock->expects($this->once())->method('addSuccess');
     $this->resultRedirectMock->expects($this->once())->method('setPath')->with('sales/order/view')->willReturnSelf();
     $result = $this->reviewPayment->execute();
     $this->assertEquals($this->resultRedirectMock, $result);
 }
 public function testEmail()
 {
     $orderId = 10000031;
     $this->request->expects($this->once())->method('getParam')->with('order_id')->will($this->returnValue($orderId));
     $this->orderRepositoryMock->expects($this->once())->method('get')->with($orderId)->willReturn($this->orderMock);
     $this->orderMock->expects($this->atLeastOnce())->method('getEntityId')->will($this->returnValue($orderId));
     $this->orderManagementMock->expects($this->once())->method('notify')->with($orderId)->willReturn(true);
     $this->messageManager->expects($this->once())->method('addSuccess')->with('You sent the order email.');
     $this->resultRedirect->expects($this->once())->method('setPath')->with('sales/order/view', ['order_id' => $orderId])->willReturnSelf();
     $this->assertInstanceOf('Magento\\Backend\\Model\\View\\Result\\Redirect', $this->orderEmail->execute());
     $this->assertEquals($this->response, $this->orderEmail->getResponse());
 }