-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
246 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Tests\Http\Requests; | ||
|
||
use Mollie\Api\Http\Payload\CreatePaymentPayload; | ||
use Mollie\Api\Http\Payload\Money; | ||
use Mollie\Api\Http\Query\CreatePaymentQuery; | ||
use Mollie\Api\Http\Requests\CreatePaymentRequest; | ||
use Mollie\Api\Http\Response; | ||
use Mollie\Api\Resources\Payment; | ||
use Tests\Fixtures\MockClient; | ||
use Tests\Fixtures\MockResponse; | ||
use Tests\TestCase; | ||
|
||
class CreatePaymentRequestTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function it_can_create_payment() | ||
{ | ||
$client = new MockClient([ | ||
CreatePaymentRequest::class => new MockResponse(201, 'payment'), | ||
]); | ||
|
||
$payload = new CreatePaymentPayload( | ||
'Test payment', | ||
new Money('EUR', '10.00'), | ||
'https://example.org/redirect', | ||
'https://example.org/webhook' | ||
); | ||
|
||
$request = new CreatePaymentRequest($payload); | ||
|
||
/** @var Response */ | ||
$response = $client->send($request); | ||
|
||
$this->assertTrue($response->successful()); | ||
$this->assertInstanceOf(Payment::class, $response->toResource()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace Tests\Http\Requests; | ||
|
||
use Mollie\Api\Http\Requests\DynamicGetRequest; | ||
use Mollie\Api\Http\Requests\GetPaginatedPaymentsRequest; | ||
use Mollie\Api\Http\Response; | ||
use Mollie\Api\Resources\LazyCollection; | ||
use Mollie\Api\Resources\Payment; | ||
use Mollie\Api\Resources\PaymentCollection; | ||
use Tests\Fixtures\MockClient; | ||
use Tests\Fixtures\MockResponse; | ||
use Tests\TestCase; | ||
|
||
class GetPaginatedPaymentsRequestTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function it_can_get_paginated_payments() | ||
{ | ||
$client = new MockClient([ | ||
GetPaginatedPaymentsRequest::class => new MockResponse(200, 'payment-list'), | ||
]); | ||
|
||
$request = new GetPaginatedPaymentsRequest(); | ||
|
||
/** @var Response */ | ||
$response = $client->send($request); | ||
|
||
$this->assertTrue($response->successful()); | ||
|
||
/** @var PaymentCollection */ | ||
$payments = $response->toResource(); | ||
// Assert response was properly handled | ||
$this->assertInstanceOf(PaymentCollection::class, $payments); | ||
$this->assertGreaterThan(0, $payments->count()); | ||
|
||
foreach ($payments as $payment) { | ||
$this->assertInstanceOf(Payment::class, $payment); | ||
$this->assertEquals('payment', $payment->resource); | ||
} | ||
} | ||
|
||
/** @test */ | ||
public function it_can_iterate_over_payments() | ||
{ | ||
$client = new MockClient([ | ||
GetPaginatedPaymentsRequest::class => new MockResponse(200, 'payment-list'), | ||
DynamicGetRequest::class => new MockResponse(200, 'payment-list'), | ||
Check failure on line 48 in tests/Http/Requests/GetPaginatedPaymentsRequestTest.php GitHub Actions / PHP - 7.4
Check failure on line 48 in tests/Http/Requests/GetPaginatedPaymentsRequestTest.php GitHub Actions / PHP - 8
Check failure on line 48 in tests/Http/Requests/GetPaginatedPaymentsRequestTest.php GitHub Actions / PHP - 8.1
Check failure on line 48 in tests/Http/Requests/GetPaginatedPaymentsRequestTest.php GitHub Actions / PHP - 8.2
Check failure on line 48 in tests/Http/Requests/GetPaginatedPaymentsRequestTest.php GitHub Actions / PHP - 8.3
|
||
DynamicGetRequest::class => new MockResponse(200, 'empty-list', 'payments'), | ||
]); | ||
|
||
$request = (new GetPaginatedPaymentsRequest())->useIterator(); | ||
|
||
/** @var Response */ | ||
$response = $client->send($request); | ||
$this->assertTrue($response->successful()); | ||
|
||
/** @var LazyCollection */ | ||
$payments = $response->toResource(); | ||
|
||
foreach ($payments as $payment) { | ||
$this->assertInstanceOf(Payment::class, $payment); | ||
} | ||
} | ||
} |
Oops, something went wrong.