@@ -158,6 +158,8 @@ function ($value) {
158
158
'getBaseTotalRefunded ' ,
159
159
'getItemsCollection ' ,
160
160
'getOrder ' ,
161
+ 'register ' ,
162
+ 'capture ' ,
161
163
]
162
164
)
163
165
->getMock ();
@@ -454,6 +456,56 @@ public function testPlaceActionAuthorizeFraud()
454
456
$ this ->assertEquals ($ sum , $ this ->payment ->getAmountAuthorized ());
455
457
}
456
458
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
+
457
509
public function testAuthorize ()
458
510
{
459
511
$ storeID = 1 ;
0 commit comments