public function testCapture() { $baseGrandTotal = 10; $order = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->getMock(); $paymentMethod = $this->getMockBuilder('Magento\\Payment\\Model\\MethodInterface')->disableOriginalConstructor()->getMock(); $orderPayment = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Payment')->disableOriginalConstructor()->getMock(); $orderPayment->expects($this->any())->method('formatAmount')->with($baseGrandTotal)->willReturnArgument(0); $orderPayment->expects($this->any())->method('getOrder')->willReturn($order); $orderPayment->expects($this->any())->method('getMethodInstance')->willReturn($paymentMethod); $orderPayment->expects($this->once())->method('getIsTransactionPending')->willReturn(true); $orderPayment->expects($this->once())->method('getTransactionAdditionalInfo')->willReturn([]); $paymentMethod->expects($this->once())->method('capture')->with($orderPayment, $baseGrandTotal); $this->transactionBuilder->expects($this->once())->method('setPayment')->with($orderPayment)->willReturnSelf(); $invoice = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Invoice')->disableOriginalConstructor()->getMock(); $invoice->expects($this->any())->method('getBaseGrandTotal')->willReturn($baseGrandTotal); $this->model->capture($orderPayment, $invoice); }
/** * Process capture operation * * @param OrderPaymentInterface $payment * @param InvoiceInterface $invoice * @return OrderPaymentInterface|Payment * @throws \Magento\Framework\Exception\LocalizedException */ public function capture(OrderPaymentInterface $payment, $invoice) { return $this->captureOperation->capture($payment, $invoice); }