From 7e6b6a61b8f7a23fe77a45ffd747d9866cbf6d70 Mon Sep 17 00:00:00 2001 From: Krishan Koenig Date: Mon, 23 Dec 2024 16:06:54 +0100 Subject: [PATCH] wip --- examples/client-links/create-client-link.php | 21 +++++++++++-------- .../PaymentEndpointCollection.php | 2 +- .../GetPaginatedPaymentsRequestTest.php | 3 ++- tests/Http/Requests/GetPaymentRequestTest.php | 9 +++----- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/examples/client-links/create-client-link.php b/examples/client-links/create-client-link.php index 941a1bab..ea60a6f6 100644 --- a/examples/client-links/create-client-link.php +++ b/examples/client-links/create-client-link.php @@ -27,13 +27,16 @@ * * See: https://docs.mollie.com/reference/v2/client-links-api/create-client-link */ - $response = $mollie->send(new CreateClientLinkRequest(new CreateClientLinkPayload( - new Owner('foo@test.com', 'foo', 'bar', 'nl_NL'), - 'Foo Company', - new OwnerAddress('NL', 'Keizersgracht 313', '1016 EE', 'Amsterdam'), - '30204462', - 'NL123456789B01', - ))); + $response = $mollie + ->send( + new CreateClientLinkRequest(new CreateClientLinkPayload( + new Owner('foo@test.com', 'foo', 'bar', 'nl_NL'), + 'Foo Company', + new OwnerAddress('NL', 'Keizersgracht 313', '1016 EE', 'Amsterdam'), + '30204462', + 'NL123456789B01', + )) + ); $clientLink = $response->toResource(); @@ -53,7 +56,7 @@ * Send the customer off to finalize the organization creation. * This request should always be a GET, thus we enforce 303 http response code */ - header('Location: '.$redirectUrl, true, 303); + header('Location: ' . $redirectUrl, true, 303); } catch (\Mollie\Api\Exceptions\ApiException $e) { - echo 'API call failed: '.htmlspecialchars($e->getMessage()); + echo 'API call failed: ' . htmlspecialchars($e->getMessage()); } diff --git a/src/EndpointCollection/PaymentEndpointCollection.php b/src/EndpointCollection/PaymentEndpointCollection.php index 9926833b..9f383c1d 100644 --- a/src/EndpointCollection/PaymentEndpointCollection.php +++ b/src/EndpointCollection/PaymentEndpointCollection.php @@ -33,7 +33,7 @@ class PaymentEndpointCollection extends EndpointCollection * * Will throw a ApiException if the payment id is invalid or the resource cannot be found. * - * + * @param array|GetPaymentQuery $query * @throws ApiException */ public function get(string $id, $query = [], bool $testmode = false): Payment diff --git a/tests/Http/Requests/GetPaginatedPaymentsRequestTest.php b/tests/Http/Requests/GetPaginatedPaymentsRequestTest.php index 8f3a97a9..44399f2c 100644 --- a/tests/Http/Requests/GetPaginatedPaymentsRequestTest.php +++ b/tests/Http/Requests/GetPaginatedPaymentsRequestTest.php @@ -8,6 +8,7 @@ use Mollie\Api\Http\Requests\DynamicGetRequest; use Mollie\Api\Http\Requests\GetPaginatedPaymentsRequest; use Mollie\Api\Http\Response; +use Mollie\Api\MollieApiClient; use Mollie\Api\Resources\LazyCollection; use Mollie\Api\Resources\Payment; use Mollie\Api\Resources\PaymentCollection; @@ -42,7 +43,7 @@ public function it_can_get_paginated_payments() /** @test */ public function it_can_iterate_over_payments() { - $client = new MockMollieClient([ + $client = MollieApiClient::fake([ GetPaginatedPaymentsRequest::class => MockResponse::ok('payment-list'), DynamicGetRequest::class => new SequenceMockResponse( MockResponse::ok('payment-list'), diff --git a/tests/Http/Requests/GetPaymentRequestTest.php b/tests/Http/Requests/GetPaymentRequestTest.php index 9df8e29c..c7e4e22c 100644 --- a/tests/Http/Requests/GetPaymentRequestTest.php +++ b/tests/Http/Requests/GetPaymentRequestTest.php @@ -2,9 +2,9 @@ namespace Tests\Http\Requests; -use Mollie\Api\Fake\MockMollieClient; use Mollie\Api\Fake\MockResponse; use Mollie\Api\Http\Requests\GetPaymentRequest; +use Mollie\Api\MollieApiClient; use Mollie\Api\Resources\Payment; use PHPUnit\Framework\TestCase; @@ -13,15 +13,12 @@ class GetPaymentRequestTest extends TestCase /** @test */ public function it_can_get_payment() { - $client = new MockMollieClient([ + $client = MollieApiClient::fake([ GetPaymentRequest::class => MockResponse::ok('payment'), ]); - $paymentId = 'tr_WDqYK6vllg'; - $request = new GetPaymentRequest($paymentId); - /** @var Payment */ - $payment = $client->send($request); + $payment = $client->send(new GetPaymentRequest('tr_WDqYK6vllg')); $this->assertTrue($payment->getResponse()->successful()); $this->assertInstanceOf(Payment::class, $payment);