public function testPlace() { $newOrderStatus = 'new_status'; /** @var \Magento\Sales\Model\Order\Config | \PHPUnit_Framework_MockObject_MockObject $orderConfigMock */ $orderConfigMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Config')->disableOriginalConstructor()->setMethods(['getStateStatuses', 'getStateDefaultStatus'])->getMock(); $orderConfigMock->expects($this->once())->method('getStateStatuses')->with(\Magento\Sales\Model\Order::STATE_NEW)->will($this->returnValue(['firstStatus', 'secondStatus'])); $orderConfigMock->expects($this->once())->method('getStateDefaultStatus')->with(\Magento\Sales\Model\Order::STATE_NEW)->will($this->returnValue($newOrderStatus)); $this->orderMock->expects($this->exactly(2))->method('getConfig')->will($this->returnValue($orderConfigMock)); $this->orderMock->expects($this->once())->method('setState')->with(\Magento\Sales\Model\Order::STATE_NEW, $newOrderStatus); $this->paymentMethodMock->expects($this->once())->method('getConfigPaymentAction')->willReturn(null); $this->eventManagerMock->expects($this->at(0))->method('dispatch')->with('sales_order_payment_place_start', ['payment' => $this->payment]); $this->eventManagerMock->expects($this->at(1))->method('dispatch')->with('sales_order_payment_place_end', ['payment' => $this->payment]); $this->assertEquals($this->payment, $this->payment->place()); }
public function testPlaceActionAuthorizeCapture() { $newOrderStatus = 'new_status'; $customerNote = 'blabla'; $sum = 10; $this->orderMock->expects($this->any())->method('getTotalDue')->willReturn($sum); $this->orderMock->expects($this->any())->method('getBaseTotalDue')->willReturn($sum); $this->helperMock->expects($this->once())->method('getMethodInstance')->will($this->returnValue($this->paymentMethodMock)); $this->paymentMethodMock->expects($this->once())->method('getConfigPaymentAction')->willReturn(\Magento\Payment\Model\Method\AbstractMethod::ACTION_AUTHORIZE_CAPTURE); $this->paymentMethodMock->expects($this->any())->method('getConfigData')->with('order_status', null)->willReturn($newOrderStatus); $statusHistory = $this->getMockForAbstractClass('Magento\\Sales\\Api\\Data\\OrderStatusHistoryInterface'); $this->invoiceMock->expects($this->once())->method('register')->willReturnSelf(); $this->invoiceMock->expects($this->once())->method('capture')->willReturnSelf(); $this->paymentMethodMock->expects($this->once())->method('canCapture')->willReturn(true); $this->orderMock->expects($this->any())->method('prepareInvoice')->willReturn($this->invoiceMock); $this->orderMock->expects($this->once())->method('addRelatedObject')->with($this->invoiceMock); $this->orderMock->expects($this->any())->method('getCustomerNote')->willReturn($customerNote); $this->orderMock->expects($this->any())->method('addStatusHistoryComment')->with($customerNote)->willReturn($statusHistory); $this->mockGetDefaultStatus(Order::STATE_PROCESSING, $newOrderStatus, ['first', 'second']); $this->orderMock->expects($this->any())->method('setState')->with(Order::STATE_PROCESSING)->willReturnSelf(); $this->orderMock->expects($this->any())->method('setStatus')->with($newOrderStatus)->willReturnSelf(); $this->paymentMethodMock->expects($this->once())->method('getConfigPaymentAction')->willReturn(null); $this->assertEquals($this->payment, $this->payment->place()); $this->assertEquals($this->invoiceMock, $this->payment->getCreatedInvoice()); $this->assertEquals($sum, $this->payment->getAmountAuthorized()); $this->assertEquals($sum, $this->payment->getBaseAmountAuthorized()); }
public function testPlace() { $newOrderStatus = 'new_status'; $this->helperMock->expects($this->once())->method('getMethodInstance')->will($this->returnValue($this->paymentMethodMock)); $this->mockGetDefaultStatus(Order::STATE_NEW, $newOrderStatus, ['first', 'second']); $this->assertOrderUpdated(Order::STATE_NEW, $newOrderStatus); $this->paymentMethodMock->expects($this->once())->method('getConfigPaymentAction')->willReturn(null); $this->eventManagerMock->expects($this->at(0))->method('dispatch')->with('sales_order_payment_place_start', ['payment' => $this->payment]); $this->eventManagerMock->expects($this->at(1))->method('dispatch')->with('sales_order_payment_place_end', ['payment' => $this->payment]); $this->assertEquals($this->payment, $this->payment->place()); }
/** * {@inheritdoc} */ public function place() { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'place'); if (!$pluginInfo) { return parent::place(); } else { return $this->___callPlugins('place', func_get_args(), $pluginInfo); } }