Skip to content

Commit

Permalink
[EPC-9489] Write unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Can Demiralp committed Jan 29, 2025
1 parent 1418b44 commit 006bfde
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Test/Unit/Observer/InvoiceObserverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Adyen\Payment\Helper\Invoice as InvoiceHelper;
use Adyen\Payment\Helper\PaymentMethods;
use Adyen\Payment\Logger\AdyenLogger;
use Adyen\Payment\Model\Order\Payment;
use Adyen\Payment\Observer\InvoiceObserver;
use Adyen\Payment\Test\Unit\AbstractAdyenTestCase;
use Magento\Framework\Event\Observer;
Expand Down Expand Up @@ -90,6 +91,12 @@ private static function skipObserverDataSet(): array
'isPaid' => false,
'isFinalized' => true,
'shouldExecute' => false
],
[
'isAdyenPaymentMethod' => true,
'isPaid' => false,
'isFinalized' => false,
'shouldExecute' => true
]
];
}
Expand All @@ -112,7 +119,7 @@ public function testExecute(
) {
$method = 'method_name';
$paymentId = 1;
$linkedAmount = 1000;
$linkedAmount = 1000.00;
$status = 'payment_review';

$paymentMock = $this->createMock(Order\Payment::class);
Expand Down Expand Up @@ -148,7 +155,7 @@ public function testExecute(
if ($shouldExecute) {
// Assert required method calls

$adyenOrderPayments[] = $this->createMock(OrderPaymentInterface::class);
$adyenOrderPayments[] = $this->createMock(Payment::class);
$this->adyenOrderPaymentRepositoryMock->expects($this->once())
->method('getByPaymentId')
->with($paymentId, [
Expand Down Expand Up @@ -179,7 +186,7 @@ public function testExecute(
->method('setStatus')
->with($status);

$this->adyenLoggerMock->expects($this->once())->method('addAdyenDebug');
$this->adyenLoggerMock->expects($this->any())->method('addAdyenDebug');
} else {
// Under these circumstances, observer shouldn't intercept the code. Assert not calling methods.

Expand Down

0 comments on commit 006bfde

Please sign in to comment.