From 8de3d9d14d7288f75ef819145846ab3888ccdcc9 Mon Sep 17 00:00:00 2001 From: Francois-Gomis Date: Mon, 20 Jan 2025 20:39:22 +0100 Subject: [PATCH] fix: type and lint --- src/Endpoints/Merchants.php | 2 +- .../OrderConfirmedBusinessEvent.php | 2 +- tests/Unit/Endpoints/MerchantsTest.php | 15 +++++---------- .../OrderConfirmedBusinessEventTest.php | 2 +- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/Endpoints/Merchants.php b/src/Endpoints/Merchants.php index 19c5976..59c9aef 100644 --- a/src/Endpoints/Merchants.php +++ b/src/Endpoints/Merchants.php @@ -101,7 +101,7 @@ public function sendCartInitiatedBusinessEvent(CartInitiatedBusinessEvent $cartE } /** - * Prepare and send a business event for a cart initiated + * Prepare and send a business event for Order confirmed * * @param OrderConfirmedBusinessEvent $orderConfirmedBusinessEvent * @return void diff --git a/src/Entities/DTO/MerchantBusinessEvent/OrderConfirmedBusinessEvent.php b/src/Entities/DTO/MerchantBusinessEvent/OrderConfirmedBusinessEvent.php index 1ec9466..a4a10b9 100644 --- a/src/Entities/DTO/MerchantBusinessEvent/OrderConfirmedBusinessEvent.php +++ b/src/Entities/DTO/MerchantBusinessEvent/OrderConfirmedBusinessEvent.php @@ -29,7 +29,7 @@ class OrderConfirmedBusinessEvent extends AbstractBusinessEvent */ private $cartId; /** - * @var string + * @var string | null */ private $almaPaymentId; diff --git a/tests/Unit/Endpoints/MerchantsTest.php b/tests/Unit/Endpoints/MerchantsTest.php index b486291..d65ea68 100644 --- a/tests/Unit/Endpoints/MerchantsTest.php +++ b/tests/Unit/Endpoints/MerchantsTest.php @@ -6,7 +6,6 @@ use Alma\API\Endpoints\Merchants; use Alma\API\Entities\DTO\MerchantBusinessEvent\CartInitiatedBusinessEvent; use Alma\API\Entities\DTO\MerchantBusinessEvent\OrderConfirmedBusinessEvent; -use Alma\API\Exceptions\ParametersException; use Alma\API\Exceptions\RequestException; use Alma\API\Request; use Alma\API\RequestError; @@ -45,6 +44,7 @@ public function setUp(): void $this->clientContext->logger = $loggerMock; $this->merchantEndpoint->setClientContext($this->clientContext); } + public function tearDown(): void { $this->merchantEndpoint = null; @@ -69,6 +69,7 @@ public function testSendBusinessEventPostThrowRequestErrorThrowRequestException( $this->expectException(RequestException::class); $this->merchantEndpoint->sendCartInitiatedBusinessEvent(new CartInitiatedBusinessEvent('42')); } + public function testSendBusinessEventBadResponseRequestException() { $this->merchantEndpoint->shouldReceive('request') @@ -88,10 +89,7 @@ public function testSendBusinessEventBadResponseRequestException() $this->expectException(RequestException::class); $this->merchantEndpoint->sendCartInitiatedBusinessEvent(new CartInitiatedBusinessEvent('42')); } - /** - * - * @return void - */ + public function testSendCartInitiatedEvent() { $cartInitiatedEvent = new CartInitiatedBusinessEvent('42'); @@ -107,10 +105,7 @@ public function testSendCartInitiatedEvent() $this->requestObject->shouldReceive('post')->once()->andReturn($this->responseMock); $this->assertNull($this->merchantEndpoint->sendCartInitiatedBusinessEvent($cartInitiatedEvent)); } - /** - * - * @return void - */ + public function testSendOrderConfirmedBusinessEventForNonAlmaPayment() { $orderConfirmedBusinessEvent = new OrderConfirmedBusinessEvent( @@ -142,6 +137,7 @@ public function testSendOrderConfirmedBusinessEventForNonAlmaPayment() $this->requestObject->shouldReceive('post')->once()->andReturn($this->responseMock); $this->assertNull($this->merchantEndpoint->sendOrderConfirmedBusinessEvent($orderConfirmedBusinessEvent)); } + public function testSendOrderConfirmedBusinessEventForAlmaPayment() { $orderConfirmedBusinessEvent = new OrderConfirmedBusinessEvent( @@ -174,5 +170,4 @@ public function testSendOrderConfirmedBusinessEventForAlmaPayment() $this->requestObject->shouldReceive('post')->once()->andReturn($this->responseMock); $this->assertNull($this->merchantEndpoint->sendOrderConfirmedBusinessEvent($orderConfirmedBusinessEvent)); } - } \ No newline at end of file diff --git a/tests/Unit/Entities/DTO/MerchantBusinessEvent/OrderConfirmedBusinessEventTest.php b/tests/Unit/Entities/DTO/MerchantBusinessEvent/OrderConfirmedBusinessEventTest.php index 37a52b1..8c3d6ed 100644 --- a/tests/Unit/Entities/DTO/MerchantBusinessEvent/OrderConfirmedBusinessEventTest.php +++ b/tests/Unit/Entities/DTO/MerchantBusinessEvent/OrderConfirmedBusinessEventTest.php @@ -52,6 +52,7 @@ public function testAlmaPaymentIdIsMandatoryForBnplAlmaPayment() $this->expectException(ParametersException::class); new OrderConfirmedBusinessEvent(false, true, true, "42", "54"); } + public function testAlmaPaymentIdShouldBeAbsentForNonAlmaPayments() { $this->expectException(ParametersException::class); @@ -92,7 +93,6 @@ public function testAlmaPaymentIdDataForAlmaPayment() } } - public static function invalidDataForBusinessEventDataProvider() { return [