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\AccountClient;
|
||||
use App\BusProNet\Model\Address;
|
||||
use App\BusProNet\Model\Communication;
|
||||
use App\BusProNet\Model\Notification;
|
||||
@@ -20,14 +20,14 @@ use Psr\Log\LoggerInterface;
|
||||
|
||||
class ParticipantDataPrefillerTest extends TestCase
|
||||
{
|
||||
private ApiClient $apiClient;
|
||||
private AccountClient $accountClient;
|
||||
private Crypt $crypt;
|
||||
private LoggerInterface $logger;
|
||||
private ?ParticipantDataPrefiller $service = null;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->apiClient = $this->createStub(ApiClient::class);
|
||||
$this->accountClient = $this->createStub(AccountClient::class);
|
||||
$this->crypt = $this->createStub(Crypt::class);
|
||||
$this->logger = $this->createStub(LoggerInterface::class);
|
||||
}
|
||||
@@ -35,7 +35,7 @@ class ParticipantDataPrefillerTest extends TestCase
|
||||
private function service(): ParticipantDataPrefiller
|
||||
{
|
||||
return $this->service ??= new ParticipantDataPrefiller(
|
||||
$this->apiClient,
|
||||
$this->accountClient,
|
||||
$this->crypt,
|
||||
$this->logger
|
||||
);
|
||||
@@ -43,7 +43,7 @@ class ParticipantDataPrefillerTest extends TestCase
|
||||
|
||||
public function testPrepopulateApplicantWithCompletePersonalData(): void
|
||||
{
|
||||
$this->apiClient = $this->createMock(ApiClient::class);
|
||||
$this->accountClient = $this->createMock(AccountClient::class);
|
||||
$this->crypt = $this->createMock(Crypt::class);
|
||||
|
||||
$user = $this->createUser('[email protected]', 'encrypted_password');
|
||||
@@ -57,7 +57,7 @@ class ParticipantDataPrefillerTest extends TestCase
|
||||
->with('encrypted_password')
|
||||
->willReturn('decrypted_password');
|
||||
|
||||
$this->apiClient->expects($this->once())
|
||||
$this->accountClient->expects($this->once())
|
||||
->method('getPersonalData')
|
||||
->with('[email protected]', 'decrypted_password')
|
||||
->willReturn($personalData);
|
||||
@@ -94,7 +94,7 @@ class ParticipantDataPrefillerTest extends TestCase
|
||||
|
||||
public function testPrepopulateApplicantWithPartialPersonalData(): void
|
||||
{
|
||||
$this->apiClient = $this->createMock(ApiClient::class);
|
||||
$this->accountClient = $this->createMock(AccountClient::class);
|
||||
$this->crypt = $this->createMock(Crypt::class);
|
||||
|
||||
$user = $this->createUser('[email protected]', 'encrypted_password');
|
||||
@@ -107,7 +107,7 @@ class ParticipantDataPrefillerTest extends TestCase
|
||||
->method('decrypt')
|
||||
->willReturn('decrypted_password');
|
||||
|
||||
$this->apiClient->expects($this->once())
|
||||
$this->accountClient->expects($this->once())
|
||||
->method('getPersonalData')
|
||||
->willReturn($personalData);
|
||||
|
||||
@@ -132,7 +132,7 @@ class ParticipantDataPrefillerTest extends TestCase
|
||||
|
||||
public function testPrepopulateApplicantWithApiNotificationError(): void
|
||||
{
|
||||
$this->apiClient = $this->createMock(ApiClient::class);
|
||||
$this->accountClient = $this->createMock(AccountClient::class);
|
||||
$this->crypt = $this->createMock(Crypt::class);
|
||||
$this->logger = $this->createMock(LoggerInterface::class);
|
||||
|
||||
@@ -146,7 +146,7 @@ class ParticipantDataPrefillerTest extends TestCase
|
||||
->method('decrypt')
|
||||
->willReturn('decrypted_password');
|
||||
|
||||
$this->apiClient->expects($this->once())
|
||||
$this->accountClient->expects($this->once())
|
||||
->method('getPersonalData')
|
||||
->willReturn($notification);
|
||||
|
||||
@@ -171,7 +171,7 @@ class ParticipantDataPrefillerTest extends TestCase
|
||||
|
||||
public function testPrepopulateApplicantWithDecryptionException(): void
|
||||
{
|
||||
$this->apiClient = $this->createMock(ApiClient::class);
|
||||
$this->accountClient = $this->createMock(AccountClient::class);
|
||||
$this->crypt = $this->createMock(Crypt::class);
|
||||
$this->logger = $this->createMock(LoggerInterface::class);
|
||||
|
||||
@@ -183,7 +183,7 @@ class ParticipantDataPrefillerTest extends TestCase
|
||||
->method('decrypt')
|
||||
->willThrowException(new \RuntimeException('Decryption failed'));
|
||||
|
||||
$this->apiClient->expects($this->never())
|
||||
$this->accountClient->expects($this->never())
|
||||
->method('getPersonalData');
|
||||
|
||||
$this->logger->expects($this->once())
|
||||
@@ -203,7 +203,7 @@ class ParticipantDataPrefillerTest extends TestCase
|
||||
|
||||
public function testPrepopulateApplicantWithApiException(): void
|
||||
{
|
||||
$this->apiClient = $this->createMock(ApiClient::class);
|
||||
$this->accountClient = $this->createMock(AccountClient::class);
|
||||
$this->crypt = $this->createMock(Crypt::class);
|
||||
$this->logger = $this->createMock(LoggerInterface::class);
|
||||
|
||||
@@ -215,7 +215,7 @@ class ParticipantDataPrefillerTest extends TestCase
|
||||
->method('decrypt')
|
||||
->willReturn('decrypted_password');
|
||||
|
||||
$this->apiClient->expects($this->once())
|
||||
$this->accountClient->expects($this->once())
|
||||
->method('getPersonalData')
|
||||
->willThrowException(new \RuntimeException('API connection failed'));
|
||||
|
||||
@@ -236,7 +236,7 @@ class ParticipantDataPrefillerTest extends TestCase
|
||||
|
||||
public function testPrepopulatePreservesBookingSpecificFields(): void
|
||||
{
|
||||
$this->apiClient = $this->createMock(ApiClient::class);
|
||||
$this->accountClient = $this->createMock(AccountClient::class);
|
||||
$this->crypt = $this->createMock(Crypt::class);
|
||||
|
||||
$user = $this->createUser('[email protected]', 'encrypted_password');
|
||||
@@ -251,7 +251,7 @@ class ParticipantDataPrefillerTest extends TestCase
|
||||
->method('decrypt')
|
||||
->willReturn('decrypted_password');
|
||||
|
||||
$this->apiClient->expects($this->once())
|
||||
$this->accountClient->expects($this->once())
|
||||
->method('getPersonalData')
|
||||
->willReturn($personalData);
|
||||
|
||||
|
||||
Reference in new issue
Block a user