From 006bfde4dd18781c323db61759a14b1b2dd27c5f Mon Sep 17 00:00:00 2001 From: Can Demiralp Date: Wed, 29 Jan 2025 13:31:14 +0100 Subject: [PATCH] [EPC-9489] Write unit tests --- Test/Unit/Observer/InvoiceObserverTest.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Test/Unit/Observer/InvoiceObserverTest.php b/Test/Unit/Observer/InvoiceObserverTest.php index e8df3d281..d8760eb44 100644 --- a/Test/Unit/Observer/InvoiceObserverTest.php +++ b/Test/Unit/Observer/InvoiceObserverTest.php @@ -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; @@ -90,6 +91,12 @@ private static function skipObserverDataSet(): array 'isPaid' => false, 'isFinalized' => true, 'shouldExecute' => false + ], + [ + 'isAdyenPaymentMethod' => true, + 'isPaid' => false, + 'isFinalized' => false, + 'shouldExecute' => true ] ]; } @@ -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); @@ -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, [ @@ -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.