Skip to content

Commit 854801d

Browse files
author
Vladyslav Shcherbyna
committed
Merge branch 'MAGETWO-37089' into last_bugs
2 parents 64d2c6f + 6ef5507 commit 854801d

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ function ($value) {
158158
'getBaseTotalRefunded',
159159
'getItemsCollection',
160160
'getOrder',
161+
'register',
162+
'capture',
161163
]
162164
)
163165
->getMock();
@@ -454,6 +456,56 @@ public function testPlaceActionAuthorizeFraud()
454456
$this->assertEquals($sum, $this->payment->getAmountAuthorized());
455457
}
456458

459+
public function testPlaceActionAuthorizeCapture()
460+
{
461+
$newOrderStatus = 'new_status';
462+
$customerNote = 'blabla';
463+
$sum = 10;
464+
$this->orderMock->expects($this->any())->method('getTotalDue')->willReturn($sum);
465+
$this->orderMock->expects($this->any())->method('getBaseTotalDue')->willReturn($sum);
466+
$this->helperMock->expects($this->once())
467+
->method('getMethodInstance')
468+
->will($this->returnValue($this->paymentMethodMock));
469+
$this->paymentMethodMock->expects($this->once())
470+
->method('getConfigPaymentAction')
471+
->willReturn(\Magento\Payment\Model\Method\AbstractMethod::ACTION_AUTHORIZE_CAPTURE);
472+
$this->paymentMethodMock->expects($this->any())
473+
->method('getConfigData')
474+
->with('order_status', null)
475+
->willReturn($newOrderStatus);
476+
$statusHistory = $this->getMockForAbstractClass(
477+
'Magento\Sales\Api\Data\OrderStatusHistoryInterface'
478+
);
479+
$this->invoiceMock->expects($this->once())->method('register')->willReturnSelf();
480+
$this->invoiceMock->expects($this->once())->method('capture')->willReturnSelf();
481+
$this->paymentMethodMock->expects($this->once())->method('canCapture')->willReturn(true);
482+
$this->orderMock->expects($this->any())->method('prepareInvoice')->willReturn($this->invoiceMock);
483+
$this->orderMock->expects($this->once())->method('addRelatedObject')->with($this->invoiceMock);
484+
$this->orderMock->expects($this->any())->method('getCustomerNote')->willReturn($customerNote);
485+
$this->orderMock->expects($this->any())
486+
->method('addStatusHistoryComment')
487+
->with($customerNote)
488+
->willReturn($statusHistory);
489+
$this->mockGetDefaultStatus(Order::STATE_PROCESSING, $newOrderStatus, ['first', 'second']);
490+
$this->orderMock->expects($this->any())
491+
->method('setState')
492+
->with(Order::STATE_PROCESSING)
493+
->willReturnSelf();
494+
$this->orderMock->expects($this->any())
495+
->method('setStatus')
496+
->with($newOrderStatus)
497+
->willReturnSelf();
498+
$this->paymentMethodMock->expects($this->once())
499+
->method('getConfigPaymentAction')
500+
->willReturn(null);
501+
502+
$this->assertEquals($this->payment, $this->payment->place());
503+
504+
$this->assertEquals($this->invoiceMock, $this->payment->getCreatedInvoice());
505+
$this->assertEquals($sum, $this->payment->getAmountAuthorized());
506+
$this->assertEquals($sum, $this->payment->getBaseAmountAuthorized());
507+
}
508+
457509
public function testAuthorize()
458510
{
459511
$storeID = 1;

0 commit comments

Comments
 (0)