wip: guest account registration (self-service and booking create flow)
This commit is contained in:
1 parent
e4430ac5c5
commit
d74888f64b
43 files changed
+2736
-144
No files matched your search
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\BpnConnect;
|
||||
|
||||
use App\BpnConnect\BpnConnectClient;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\NullLogger;
|
||||
use Symfony\Component\HttpClient\MockHttpClient;
|
||||
use Symfony\Component\HttpClient\Response\MockResponse;
|
||||
|
||||
class BpnConnectClientTest extends TestCase
|
||||
{
|
||||
public function testLookupBookingMapsResponse(): void
|
||||
{
|
||||
$capturedMethod = null;
|
||||
$capturedUrl = null;
|
||||
$capturedOptions = null;
|
||||
$httpClient = new MockHttpClient(static function (string $method, string $url, array $options) use (&$capturedMethod, &$capturedUrl, &$capturedOptions): MockResponse {
|
||||
$capturedMethod = $method;
|
||||
$capturedUrl = $url;
|
||||
$capturedOptions = $options;
|
||||
|
||||
return new MockResponse(json_encode([
|
||||
'bookingNumber' => 111386,
|
||||
'bookingId' => 98609,
|
||||
'addressId' => 225672,
|
||||
'personId' => 412344,
|
||||
'email' => '[email protected]',
|
||||
'firstName' => 'Vorname 1',
|
||||
'lastName' => 'Mustermann 1',
|
||||
], JSON_THROW_ON_ERROR), [
|
||||
'response_headers' => ['content-type' => 'application/json'],
|
||||
]);
|
||||
}, 'https://bpn-connect.test/');
|
||||
|
||||
$booking = (new BpnConnectClient($httpClient, new NullLogger()))->lookupBooking(' [email protected] ', 111386);
|
||||
|
||||
self::assertSame('GET', $capturedMethod);
|
||||
self::assertSame('https://bpn-connect.test/api/bookings/[email protected]&bookingNumber=111386', $capturedUrl);
|
||||
self::assertSame(111386, $capturedOptions['query']['bookingNumber']);
|
||||
self::assertSame(98609, $booking?->bookingId);
|
||||
self::assertSame(225672, $booking?->addressId);
|
||||
self::assertSame(412344, $booking?->personId);
|
||||
self::assertSame('[email protected]', $booking?->email);
|
||||
self::assertSame('Vorname 1', $booking?->firstName);
|
||||
self::assertSame('Mustermann 1', $booking?->lastName);
|
||||
}
|
||||
|
||||
public function testLookupBookingReturnsNullForNotFound(): void
|
||||
{
|
||||
$httpClient = new MockHttpClient(new MockResponse('', ['http_code' => 404]), 'https://bpn-connect.test/');
|
||||
|
||||
self::assertNull((new BpnConnectClient($httpClient, new NullLogger()))->lookupBooking('[email protected]', 123));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user