Skip to content

Commit

Permalink
[ECP-8542] - Updating the Mocking of MagentoInvoice
Browse files Browse the repository at this point in the history
  • Loading branch information
khushboo-singhvi committed Nov 7, 2023
1 parent c07b53a commit 1724e52
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Test/Unit/Helper/Webhook/CaptureWebhookHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,24 @@ public function testHandleWebhookWithoutAutoCapture()
->with($adyenOrderPaymentMock, $this->notification->getAmountCurrency());

// Create a mock for the magentoInvoiceFactory
$magentoInvoiceFactoryMock = $this->createMock(MagentoInvoiceFactory::class);
$magentoInvoiceFactoryMock = $this->createGeneratedMock(MagentoInvoiceFactory::class, ['create']);

// Create a mock for MagentoInvoice
$magentoInvoiceMock = $this->createMock(MagentoInvoice::class);

// Configure the magentoInvoiceFactoryMock to return the magentoInvoiceMock
$magentoInvoiceFactoryMock->method('create')->willReturn($magentoInvoiceMock);
$magentoInvoiceMock = $this->getMockBuilder(MagentoInvoice::class)
->setMethods(['load']) // Define the method you want to mock
->disableOriginalConstructor()
->getMock();

// Configure the load method of the magentoInvoiceMock to return the same mock
$magentoInvoiceMock->expects($this->once())
->method('load')
->willReturnSelf();
->with(456, MagentoInvoice::ENTITY_ID)
->willReturnSelf(); // Return the mock itself

// Configure the magentoInvoiceFactoryMock to return the magentoInvoiceMock
$magentoInvoiceFactoryMock->expects($this->once())
->method('create')
->willReturn($magentoInvoiceMock);

$this->captureWebhookHandler = $this->createCaptureWebhookHandler(
$invoiceHelperMock,
Expand Down

0 comments on commit 1724e52

Please sign in to comment.