feat: move prepopulation guards into participant service
This commit is contained in:
@@ -10,9 +10,11 @@ use App\BusProNet\Model\Communication;
|
||||
use App\BusProNet\Model\Notification;
|
||||
use App\BusProNet\Model\PersonalData;
|
||||
use App\Entity\User;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Security\Crypt;
|
||||
use App\Service\ParticipantPrepopulationService;
|
||||
use Carbon\CarbonImmutable;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
@@ -240,6 +242,44 @@ class ParticipantPrepopulationServiceTest extends TestCase
|
||||
$this->assertTrue($result->bulkInsuranceBooking);
|
||||
}
|
||||
|
||||
public function testShouldPrepopulateApplicantOnlyWhenFresh(): void
|
||||
{
|
||||
$fresh = new ParticipantDto();
|
||||
$fresh->firstName = '';
|
||||
|
||||
$filled = new ParticipantDto();
|
||||
$filled->firstName = 'Already set';
|
||||
|
||||
$this->assertTrue($this->service->shouldPrepopulateApplicant($fresh));
|
||||
$this->assertFalse($this->service->shouldPrepopulateApplicant($filled));
|
||||
}
|
||||
|
||||
public function testDummyTokenMatchesOnlyInCreateMode(): void
|
||||
{
|
||||
$participant = new ParticipantDto();
|
||||
$participant->lastName = ParticipantPrepopulationService::TOKEN;
|
||||
|
||||
$this->assertTrue($this->service->isDummyDataFillRequested($participant, BookingDto::MODE_CREATE));
|
||||
$this->assertFalse($this->service->isDummyDataFillRequested($participant, BookingDto::MODE_EDIT));
|
||||
}
|
||||
|
||||
public function testFillDummyParticipantSetsGeneratedData(): void
|
||||
{
|
||||
CarbonImmutable::setTestNow(CarbonImmutable::create(2026, 1, 15, 14, 30));
|
||||
|
||||
$participant = new ParticipantDto();
|
||||
$this->service->fillDummyParticipant($participant, 0);
|
||||
|
||||
$this->assertSame('Vorname 1', $participant->firstName);
|
||||
$this->assertSame('Muster 1 14:30', $participant->lastName);
|
||||
$this->assertSame('0171/111111', $participant->mobile);
|
||||
$this->assertSame('[email protected]', $participant->email);
|
||||
$this->assertSame('2006-01-15', $participant->dateOfBirth?->format('Y-m-d'));
|
||||
$this->assertSame('Musterstr. 123', $participant->address?->street);
|
||||
|
||||
CarbonImmutable::setTestNow();
|
||||
}
|
||||
|
||||
private function createUser(string $email, string $encryptedPassword): User
|
||||
{
|
||||
$user = new User($email);
|
||||
|
||||
Reference in New Issue
Block a user