Skip to content

Commit

Permalink
[ECP-8888] Write unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Can Demiralp committed Feb 20, 2025
1 parent 01cb2a1 commit 55f8f17
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions Test/Unit/Helper/PaymentMethodsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1328,12 +1328,49 @@ public function testRemovePaymentMethodsActivation()

public function testIsOpenInvoice()
{
$paymentMethodInstaceMock = $this->createMock(MethodInterface::class);
$paymentMethodInstaceMock->method('getConfigData')
$paymentMethodInstanceMock = $this->createMock(MethodInterface::class);
$paymentMethodInstanceMock->method('getConfigData')
->with(PaymentMethods::CONFIG_FIELD_IS_OPEN_INVOICE)
->willReturn(true);

$result = $this->paymentMethodsHelper->isOpenInvoice($paymentMethodInstaceMock);
$result = $this->paymentMethodsHelper->isOpenInvoice($paymentMethodInstanceMock);
$this->assertTrue($result);
}

/**
* @return array
*/
private static function getRequiresLineItemsDataProvider(): array
{
return [
['isOpenInvoice' => true, 'isRequiresOpenInvoiceConfigSet' => false, 'requiresLineItems' => true],
['isOpenInvoice' => false, 'isRequiresOpenInvoiceConfigSet' => true, 'requiresLineItems' => true],
['isOpenInvoice' => false, 'isRequiresOpenInvoiceConfigSet' => false, 'requiresLineItems' => false],
['isOpenInvoice' => true, 'isRequiresOpenInvoiceConfigSet' => true, 'requiresLineItems' => true]
];
}

/**
* @dataProvider getRequiresLineItemsDataProvider()
*
* @param bool $isOpenInvoice
* @param bool $isRequiresOpenInvoiceConfigSet
* @param bool $requiresLineItems
* @return void
*/
public function testGetRequiresLineItems(
bool $isOpenInvoice,
bool $isRequiresOpenInvoiceConfigSet,
bool $requiresLineItems
) {
$paymentMethodInstanceMock = $this->createMock(MethodInterface::class);
$paymentMethodInstanceMock->method('getConfigData')
->willReturnMap([
[PaymentMethods::CONFIG_FIELD_IS_OPEN_INVOICE, null, $isOpenInvoice],
[PaymentMethods::CONFIG_FIELD_REQUIRES_LINE_ITEMS, null, $isRequiresOpenInvoiceConfigSet]
]);

$result = $this->paymentMethodsHelper->getRequiresLineItems($paymentMethodInstanceMock);
$this->assertEquals($requiresLineItems, $result);
}
}

0 comments on commit 55f8f17

Please sign in to comment.