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,7 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Service;
|
||||
|
||||
use App\BusProNet\ApiClient;
|
||||
use App\BusProNet\Client\TravelClient;
|
||||
use App\BusProNet\Exception\ApiClientException;
|
||||
use App\BusProNet\Model\ExtendedServiceAvailabilityResponse;
|
||||
use App\BusProNet\Model\Hotel;
|
||||
@@ -21,7 +21,7 @@ class TravelSnapshotManagerTest extends TestCase
|
||||
{
|
||||
private TravelSnapshotRepository $snapshotRepository;
|
||||
private EntityManagerInterface $entityManager;
|
||||
private ApiClient $apiClient;
|
||||
private TravelClient $travelClient;
|
||||
private LoggerInterface $logger;
|
||||
private SerializerInterface $serializer;
|
||||
private ?TravelSnapshotManager $service = null;
|
||||
@@ -30,7 +30,7 @@ class TravelSnapshotManagerTest extends TestCase
|
||||
{
|
||||
$this->snapshotRepository = $this->createStub(TravelSnapshotRepository::class);
|
||||
$this->entityManager = $this->createStub(EntityManagerInterface::class);
|
||||
$this->apiClient = $this->createStub(ApiClient::class);
|
||||
$this->travelClient = $this->createStub(TravelClient::class);
|
||||
$this->logger = $this->createStub(LoggerInterface::class);
|
||||
$this->serializer = $this->createStub(SerializerInterface::class);
|
||||
}
|
||||
@@ -40,7 +40,7 @@ class TravelSnapshotManagerTest extends TestCase
|
||||
return $this->service ??= new TravelSnapshotManager(
|
||||
$this->snapshotRepository,
|
||||
$this->entityManager,
|
||||
$this->apiClient,
|
||||
$this->travelClient,
|
||||
$this->logger,
|
||||
$this->serializer,
|
||||
14,
|
||||
@@ -309,7 +309,7 @@ class TravelSnapshotManagerTest extends TestCase
|
||||
{
|
||||
$this->snapshotRepository = $this->createMock(TravelSnapshotRepository::class);
|
||||
$this->entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
$this->apiClient = $this->createMock(ApiClient::class);
|
||||
$this->travelClient = $this->createMock(TravelClient::class);
|
||||
$this->serializer = $this->createMock(SerializerInterface::class);
|
||||
|
||||
$travel = new Travel();
|
||||
@@ -334,7 +334,7 @@ class TravelSnapshotManagerTest extends TestCase
|
||||
->with($oldPayload, Travel::class, 'json')
|
||||
->willReturn($travel);
|
||||
|
||||
$this->apiClient
|
||||
$this->travelClient
|
||||
->expects($this->once())
|
||||
->method('getAvailabilitiesExtended')
|
||||
->with(100)
|
||||
@@ -359,7 +359,7 @@ class TravelSnapshotManagerTest extends TestCase
|
||||
{
|
||||
$this->snapshotRepository = $this->createMock(TravelSnapshotRepository::class);
|
||||
$this->entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
$this->apiClient = $this->createMock(ApiClient::class);
|
||||
$this->travelClient = $this->createMock(TravelClient::class);
|
||||
$this->logger = $this->createMock(LoggerInterface::class);
|
||||
$this->serializer = $this->createMock(SerializerInterface::class);
|
||||
|
||||
@@ -380,7 +380,7 @@ class TravelSnapshotManagerTest extends TestCase
|
||||
->method('deserialize')
|
||||
->willReturn($travel);
|
||||
|
||||
$this->apiClient
|
||||
$this->travelClient
|
||||
->expects($this->once())
|
||||
->method('getAvailabilitiesExtended')
|
||||
->willThrowException(new ApiClientException('API error'));
|
||||
@@ -437,7 +437,7 @@ class TravelSnapshotManagerTest extends TestCase
|
||||
{
|
||||
$this->snapshotRepository = $this->createMock(TravelSnapshotRepository::class);
|
||||
$this->entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
$this->apiClient = $this->createMock(ApiClient::class);
|
||||
$this->travelClient = $this->createMock(TravelClient::class);
|
||||
|
||||
$payload = '{"id":100}';
|
||||
$snapshot = new TravelSnapshot(100, 200, $payload, hash('sha256', $payload));
|
||||
@@ -447,7 +447,7 @@ class TravelSnapshotManagerTest extends TestCase
|
||||
->method('findRefreshCandidates')
|
||||
->willReturn([$snapshot]);
|
||||
|
||||
$this->apiClient
|
||||
$this->travelClient
|
||||
->expects($this->never())
|
||||
->method('getAvailabilitiesExtended');
|
||||
|
||||
@@ -463,7 +463,7 @@ class TravelSnapshotManagerTest extends TestCase
|
||||
public function testRefreshSkipsSnapshotsWithXmlAvailable(): void
|
||||
{
|
||||
$this->snapshotRepository = $this->createMock(TravelSnapshotRepository::class);
|
||||
$this->apiClient = $this->createMock(ApiClient::class);
|
||||
$this->travelClient = $this->createMock(TravelClient::class);
|
||||
|
||||
$payload = '{"id":100}';
|
||||
$snapshot = new TravelSnapshot(100, 200, $payload, hash('sha256', $payload));
|
||||
@@ -473,7 +473,7 @@ class TravelSnapshotManagerTest extends TestCase
|
||||
->method('findRefreshCandidates')
|
||||
->willReturn([$snapshot]);
|
||||
|
||||
$this->apiClient
|
||||
$this->travelClient
|
||||
->expects($this->never())
|
||||
->method('getAvailabilitiesExtended');
|
||||
|
||||
|
||||
Reference in new issue
Block a user