Ejemplo n.º 1
0
 public function testRegisterRefundNotificationWrongAmount()
 {
     $amount = 30;
     $grandTotalCreditMemo = 50;
     $invoiceBaseGrandTotal = 50;
     $invoiceBaseTotalRefunded = 0;
     $this->invoiceMock->expects($this->any())->method('getBaseGrandTotal')->willReturn($invoiceBaseGrandTotal);
     $this->invoiceMock->expects($this->any())->method('getBaseTotalRefunded')->willReturn($invoiceBaseTotalRefunded);
     $this->creditMemoMock->expects($this->any())->method('getGrandTotal')->willReturn($grandTotalCreditMemo);
     $this->payment->setParentTransactionId($this->transactionId);
     $this->mockInvoice($this->transactionId, 1);
     $this->orderMock->expects($this->once())->method('getBaseCurrency')->willReturn($this->currencyMock);
     $parentTransaction = $this->getMock('Magento\\Sales\\Model\\Order\\Payment\\Transaction', ['setOrderId', 'setPaymentId', 'loadByTxnId', 'getId', 'getTxnId', 'getTxnType'], [], '', false);
     //generate new transaction and check if not exists
     $this->transactionRepositoryMock->expects($this->once())->method('getByTransactionId')->with($this->transactionId)->willReturn($parentTransaction);
     $newTransactionId = $this->transactionId . '-refund';
     $this->transactionManagerMock->expects($this->once())->method('isTransactionExists')->with($newTransactionId)->willReturn(false);
     $this->transactionManagerMock->expects($this->once())->method('generateTransactionId')->with($this->payment, Transaction::TYPE_REFUND, $parentTransaction)->willReturn($newTransactionId);
     $this->assertSame($this->payment, $this->payment->registerRefundNotification($amount));
 }
Ejemplo n.º 2
0
 public function testRegisterRefundNotificationWrongAmount()
 {
     $amount = 30;
     $grandTotalCreditMemo = 50;
     $invoiceBaseGrandTotal = 50;
     $invoiceBaseTotalRefunded = 0;
     $this->invoiceMock->expects($this->any())->method('getBaseGrandTotal')->willReturn($invoiceBaseGrandTotal);
     $this->invoiceMock->expects($this->any())->method('getBaseTotalRefunded')->willReturn($invoiceBaseTotalRefunded);
     $this->creditMemoMock->expects($this->any())->method('getGrandTotal')->willReturn($grandTotalCreditMemo);
     $this->payment->setParentTransactionId($this->transactionId);
     $this->mockInvoice($this->transactionId, 1);
     $this->orderMock->expects($this->once())->method('getBaseCurrency')->willReturn($this->currencyMock);
     $parentTransaction = $this->getMock('Magento\\Sales\\Model\\Order\\Payment\\Transaction', ['setOrderPaymentObject', 'loadByTxnId', 'getId', 'getTxnId', 'getTxnType'], [], '', false);
     $parentTransaction->expects($this->atLeastOnce())->method('setOrderPaymentObject')->with($this->payment)->willReturnSelf();
     $parentTransaction->expects($this->exactly(1))->method('loadByTxnId')->with($this->transactionId)->willReturnSelf();
     $newTransaction = $this->getMock('Magento\\Sales\\Model\\Order\\Payment\\Transaction', ['getId', 'setOrderPaymentObject', 'loadByTxnId', 'setTxnId', 'setTxnType', 'isFailsafe', 'getTxnId', 'getTxnType'], [], '', false);
     $this->transactionFactory->expects($this->exactly(2))->method('create')->willReturnOnConsecutiveCalls($parentTransaction, $newTransaction);
     $newTransaction->expects($this->exactly(1))->method('loadByTxnId')->with($this->transactionId . '-' . \Magento\Sales\Model\Order\Payment\Transaction::TYPE_REFUND)->willReturnSelf();
     $newTransaction->expects($this->atLeastOnce())->method('setOrderPaymentObject')->willReturnSelf();
     $this->assertSame($this->payment, $this->payment->registerRefundNotification($amount));
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function registerRefundNotification($amount)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'registerRefundNotification');
     if (!$pluginInfo) {
         return parent::registerRefundNotification($amount);
     } else {
         return $this->___callPlugins('registerRefundNotification', func_get_args(), $pluginInfo);
     }
 }