Skip to content

Commit

Permalink
Updating unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
khushboo-singhvi committed Feb 12, 2025
1 parent a5551f0 commit 62a0a1d
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions Test/Unit/Helper/Webhook/OfferClosedWebhookHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Adyen\Payment\Helper\Order;
use Adyen\Payment\Helper\PaymentMethods;
use Adyen\Payment\Logger\AdyenLogger;
use Adyen\Payment\Model\Method\Adapter;
use Adyen\Payment\Model\Notification;
use Adyen\Payment\Model\ResourceModel\Order\Payment as OrderPaymentResourceModel;
use Magento\Sales\Model\Order as MagentoOrder;
Expand Down Expand Up @@ -67,21 +68,28 @@ public function testHandleWebhookThrowsExceptionForInvalidPaymentMethod()
{
// Create a sample MagentoOrder and Notification
$order = $this->createMock(MagentoOrder::class);
$order->method('getPayment')->willReturn($this->createPartialMock(Payment::class, ['getMethod']));
$paymentMethodInstanceMock = $this->createMock(Adapter::class);
$order->method('getPayment')->willReturn($this->createPartialMock(Payment::class, ['getMethod','getMethodInstance']));
$order->getPayment()->method('getMethod')->willReturn('adyen_cc');
$order->getPayment()->method('getMethodInstance')->willReturn($paymentMethodInstanceMock);
$notification = $this->createMock(Notification::class);

// Mock payment method mismatch
$this->paymentMethodsHelper->method('compareOrderAndWebhookPaymentMethods')->with($order,$notification)->willReturn(false);
// Mock payment method comparison behavior
$this->paymentMethodsHelper->method('compareOrderAndWebhookPaymentMethods')
->with($order, $notification)
->willReturn(false);

// Create an instance of the OfferClosedWebhookHandler
$webhookHandler = $this->createOfferClosedWebhookHandler($this->paymentMethodsHelper,null,null,null,null);
$webhookHandler = $this->createOfferClosedWebhookHandler($this->paymentMethodsHelper, null, null, null, null);

// Call the handleWebhook method to trigger the exception
$result = $webhookHandler->handleWebhook($order, $notification, 'PAYMENT_REVIEW');

// Verify the expected result
$this->assertEquals($order, $result);
}


public function testHandleWebhookReturnsOrderWhenCapturedPaymentsExist()
{
// Create a sample MagentoOrder and Notification
Expand Down

0 comments on commit 62a0a1d

Please sign in to comment.