Skip to content

Commit

Permalink
[ECP-9561] Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Can Demiralp committed Dec 24, 2024
1 parent 3e5fc38 commit 362ab65
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions Test/Unit/Helper/InvoiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
namespace Adyen\Payment\Test\Unit\Helper;

use Adyen\Payment\Api\Data\InvoiceInterface;
use Adyen\Payment\Helper\ChargedCurrency;
use Adyen\Payment\Helper\Config;
use Adyen\Payment\Helper\Data;
use Adyen\Payment\Helper\Invoice;
use Adyen\Payment\Model\AdyenAmountCurrency;
use Adyen\Payment\Model\InvoiceFactory;
use Adyen\Payment\Model\Order\Payment;
use Adyen\Payment\Test\Unit\AbstractAdyenTestCase;
Expand Down Expand Up @@ -162,6 +164,13 @@ public function testHandleCaptureWebhook()
$transactionMock = $this->createGeneratedMock(Transaction::class, ['addObject']);
$transactionMock->method('addObject')->willReturn($invoiceMock);

$adyenAmountCurrencyMock = $this->createMock(AdyenAmountCurrency::class);
$adyenAmountCurrencyMock->method('getAmount')->willReturn(10);
$adyenAmountCurrencyMock->method('getCurrencyCode')->willReturn('EUR');

$chargedCurrencyMock = $this->createMock(ChargedCurrency::class);
$chargedCurrencyMock->method('getOrderAmountCurrency')->willReturn($adyenAmountCurrencyMock);

$invoiceHelper = $this->createInvoiceHelper(
$contextMock,
null,
Expand All @@ -176,7 +185,8 @@ public function testHandleCaptureWebhook()
$magentoOrderResourceModelMock,
null,
null,
$transactionMock
$transactionMock,
$chargedCurrencyMock
);

$orderPaymentMock = $this->createConfiguredMock(MagentoOrder\Payment::class, [
Expand Down Expand Up @@ -425,7 +435,8 @@ protected function createInvoiceHelper(
$magentoOrderResourceModelMock = null,
$adyenConfigHelperMock = null,
$invoiceSenderMock = null,
$transactionMock = null
$transactionMock = null,
$chargedCurrencyMock = null
): Invoice {

if (is_null($contextMock)) {
Expand Down Expand Up @@ -484,6 +495,10 @@ protected function createInvoiceHelper(
$transactionMock = $this->createGeneratedMock(Transaction::class);
}

if (is_null($chargedCurrencyMock)) {
$chargedCurrencyMock = $this->createMock(ChargedCurrency::class);
}

return new Invoice(
$contextMock,
$adyenLoggerMock,
Expand All @@ -498,7 +513,8 @@ protected function createInvoiceHelper(
$magentoOrderResourceModelMock,
$adyenConfigHelperMock,
$invoiceSenderMock,
$transactionMock
$transactionMock,
$chargedCurrencyMock
);
}
}

0 comments on commit 362ab65

Please sign in to comment.