refactor: split buspro ApiClient into domain clients
This commit is contained in:
1 parent
0a55544ca8
commit
b755a6f43e
52 files changed
+805
-695
No files matched your search
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Service;
|
||||
|
||||
use App\BusProNet\Client\BookingClient;
|
||||
use App\BusProNet\Exception\ApiClientException;
|
||||
use App\BusProNet\Exception\TimeoutException;
|
||||
use App\BusProNet\Model\Booking;
|
||||
@@ -87,14 +88,14 @@ class BookingEditSubmitterTest extends TestCase
|
||||
->with($bookingDto, $freshBookingData)
|
||||
->willReturn(false);
|
||||
|
||||
$apiClient = $this->createMock(\App\BusProNet\ApiClient::class);
|
||||
$apiClient->expects($this->once())
|
||||
$bookingClient = $this->createMock(BookingClient::class);
|
||||
$bookingClient->expects($this->once())
|
||||
->method('updateBooking')
|
||||
->with($bookingDto, true)
|
||||
->willThrowException($exception);
|
||||
|
||||
$service = $this->createService(
|
||||
apiClient: $apiClient,
|
||||
bookingClient: $bookingClient,
|
||||
dataLoader: $dataLoader,
|
||||
travelDataService: $travelDataService,
|
||||
submitGuard: $submitGuard,
|
||||
@@ -137,17 +138,17 @@ class BookingEditSubmitterTest extends TestCase
|
||||
->with($bookingDto, $freshBookingData)
|
||||
->willReturn(false);
|
||||
|
||||
$apiClient = $this->createMock(\App\BusProNet\ApiClient::class);
|
||||
$bookingClient = $this->createMock(BookingClient::class);
|
||||
$bookingUpdate = new BookingUpdate();
|
||||
$bookingUpdate->success = false;
|
||||
$bookingUpdate->status = 'BPN-FAIL';
|
||||
$apiClient->expects($this->once())
|
||||
$bookingClient->expects($this->once())
|
||||
->method('updateBooking')
|
||||
->with($bookingDto, true)
|
||||
->willReturn($bookingUpdate);
|
||||
|
||||
$service = $this->createService(
|
||||
apiClient: $apiClient,
|
||||
bookingClient: $bookingClient,
|
||||
dataLoader: $dataLoader,
|
||||
travelDataService: $travelDataService,
|
||||
submitGuard: $submitGuard,
|
||||
@@ -200,10 +201,10 @@ class BookingEditSubmitterTest extends TestCase
|
||||
->with($bookingDto, $freshBookingData)
|
||||
->willReturn(false);
|
||||
|
||||
$apiClient = $this->createMock(\App\BusProNet\ApiClient::class);
|
||||
$bookingClient = $this->createMock(BookingClient::class);
|
||||
$bookingUpdate = new BookingUpdate();
|
||||
$bookingUpdate->success = true;
|
||||
$apiClient->expects($this->once())
|
||||
$bookingClient->expects($this->once())
|
||||
->method('updateBooking')
|
||||
->with($bookingDto, true)
|
||||
->willReturn($bookingUpdate);
|
||||
@@ -221,7 +222,7 @@ class BookingEditSubmitterTest extends TestCase
|
||||
->with($user, 42);
|
||||
|
||||
$service = $this->createService(
|
||||
apiClient: $apiClient,
|
||||
bookingClient: $bookingClient,
|
||||
dataLoader: $dataLoader,
|
||||
draftService: $draftService,
|
||||
travelDataService: $travelDataService,
|
||||
@@ -267,10 +268,10 @@ class BookingEditSubmitterTest extends TestCase
|
||||
->with($bookingDto, $freshBookingData)
|
||||
->willReturn(true);
|
||||
|
||||
$apiClient = $this->createMock(\App\BusProNet\ApiClient::class);
|
||||
$bookingClient = $this->createMock(BookingClient::class);
|
||||
$bookingUpdate = new BookingUpdate();
|
||||
$bookingUpdate->success = true;
|
||||
$apiClient->expects($this->once())
|
||||
$bookingClient->expects($this->once())
|
||||
->method('updateBooking')
|
||||
->with($bookingDto, true)
|
||||
->willReturn($bookingUpdate);
|
||||
@@ -289,7 +290,7 @@ class BookingEditSubmitterTest extends TestCase
|
||||
->with($user, 42);
|
||||
|
||||
$service = $this->createService(
|
||||
apiClient: $apiClient,
|
||||
bookingClient: $bookingClient,
|
||||
dataLoader: $dataLoader,
|
||||
draftService: $draftService,
|
||||
travelDataService: $travelDataService,
|
||||
@@ -352,14 +353,14 @@ class BookingEditSubmitterTest extends TestCase
|
||||
->with($bookingDto, $freshBookingData)
|
||||
->willReturn(false);
|
||||
|
||||
$apiClient = $this->createMock(\App\BusProNet\ApiClient::class);
|
||||
$apiClient->expects($this->once())
|
||||
$bookingClient = $this->createMock(BookingClient::class);
|
||||
$bookingClient->expects($this->once())
|
||||
->method('updateBooking')
|
||||
->with($bookingDto, true)
|
||||
->willReturn($notification);
|
||||
|
||||
$service = $this->createService(
|
||||
apiClient: $apiClient,
|
||||
bookingClient: $bookingClient,
|
||||
dataLoader: $dataLoader,
|
||||
travelDataService: $travelDataService,
|
||||
submitGuard: $submitGuard,
|
||||
@@ -407,14 +408,14 @@ class BookingEditSubmitterTest extends TestCase
|
||||
->with($bookingDto, $freshBookingData)
|
||||
->willReturn(false);
|
||||
|
||||
$apiClient = $this->createMock(\App\BusProNet\ApiClient::class);
|
||||
$apiClient->expects($this->once())
|
||||
$bookingClient = $this->createMock(BookingClient::class);
|
||||
$bookingClient->expects($this->once())
|
||||
->method('updateBooking')
|
||||
->with($bookingDto, true)
|
||||
->willThrowException($exception);
|
||||
|
||||
$service = $this->createService(
|
||||
apiClient: $apiClient,
|
||||
bookingClient: $bookingClient,
|
||||
dataLoader: $dataLoader,
|
||||
travelDataService: $travelDataService,
|
||||
submitGuard: $submitGuard,
|
||||
@@ -428,7 +429,7 @@ class BookingEditSubmitterTest extends TestCase
|
||||
}
|
||||
|
||||
private function createService(
|
||||
?\App\BusProNet\ApiClient $apiClient = null,
|
||||
?BookingClient $bookingClient = null,
|
||||
?BookingEditDataLoader $dataLoader = null,
|
||||
?BookingEditDraftManager $draftService = null,
|
||||
?TravelDataProvider $travelDataService = null,
|
||||
@@ -436,7 +437,7 @@ class BookingEditSubmitterTest extends TestCase
|
||||
?BookingSessionManager $bookingSessionService = null,
|
||||
): BookingEditSubmitter {
|
||||
return new BookingEditSubmitter(
|
||||
$apiClient ?? $this->createStub(\App\BusProNet\ApiClient::class),
|
||||
$bookingClient ?? $this->createStub(BookingClient::class),
|
||||
$dataLoader ?? $this->createStub(BookingEditDataLoader::class),
|
||||
$draftService ?? $this->createStub(BookingEditDraftManager::class),
|
||||
$travelDataService ?? $this->createStub(TravelDataProvider::class),
|
||||
|
||||
Reference in new issue
Block a user