From ddd95f9142b27a3fa724fbc3580ad1ec3ecd271a Mon Sep 17 00:00:00 2001 From: Oleksii Skorobogatko Date: Mon, 9 Sep 2024 20:16:36 +0300 Subject: [PATCH] #14 refactor to be more clear from what param created --- src/Controller/Api/V1/PaymentController.php | 2 +- src/Dto/PaymentStatusDto.php | 2 +- tests/Unit/Dto/PaymentStatusDtoTest.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Controller/Api/V1/PaymentController.php b/src/Controller/Api/V1/PaymentController.php index b214b0e..81db638 100644 --- a/src/Controller/Api/V1/PaymentController.php +++ b/src/Controller/Api/V1/PaymentController.php @@ -115,6 +115,6 @@ public function getPaymentStatus( $event = $this->eventDispatcher->dispatch(new PaymentStatusEvent($order, $statusResponse)); $statusResponse = $event->paymentStatusResponse; - return $this->json(PaymentStatusDto::makeFromResponse($paymentGateway->getId(), $statusResponse)); + return $this->json(PaymentStatusDto::makeFromPaymentGatewayResponse($paymentGateway->getId(), $statusResponse)); } } diff --git a/src/Dto/PaymentStatusDto.php b/src/Dto/PaymentStatusDto.php index 76edefa..c21d4cf 100644 --- a/src/Dto/PaymentStatusDto.php +++ b/src/Dto/PaymentStatusDto.php @@ -37,7 +37,7 @@ public function __construct( ) { } - public static function makeFromResponse( + public static function makeFromPaymentGatewayResponse( string $paymentGatewayId, ResponseInterface $response, ): self { diff --git a/tests/Unit/Dto/PaymentStatusDtoTest.php b/tests/Unit/Dto/PaymentStatusDtoTest.php index f219dee..067f340 100644 --- a/tests/Unit/Dto/PaymentStatusDtoTest.php +++ b/tests/Unit/Dto/PaymentStatusDtoTest.php @@ -19,7 +19,7 @@ public function testCastToStringPaymentResponseValues(): void $response->method('getCode')->willReturn(null); $response->method('getRawData')->willReturn(false); - $dto = PaymentStatusDto::makeFromResponse('123', $response); + $dto = PaymentStatusDto::makeFromPaymentGatewayResponse('123', $response); $this->assertEquals('123', $dto->paymentGatewayId); $this->assertEquals('', $dto->message); @@ -40,7 +40,7 @@ public function testPaymentStatusDataAlwaysCastToArray(mixed $data, $expected): $response->method('getCode')->willReturn(null); $response->method('getRawData')->willReturn($data); - $dto = PaymentStatusDto::makeFromResponse('123', $response); + $dto = PaymentStatusDto::makeFromPaymentGatewayResponse('123', $response); $this->assertEquals($expected, $dto->data); }