feat: move prepopulation guards into participant service
This commit is contained in:
@@ -12,7 +12,6 @@ use App\Form\Model\ParticipantDto;
|
||||
use App\Form\Model\RoomSelectionDto;
|
||||
use App\Service\BookingParticipantCountService;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
|
||||
class BookingParticipantCountServiceTest extends TestCase
|
||||
{
|
||||
@@ -44,31 +43,6 @@ class BookingParticipantCountServiceTest extends TestCase
|
||||
$this->assertSame(7, $bookingDto->participants[7]->index);
|
||||
}
|
||||
|
||||
public function testEnsureCorrectNumberOfParticipantsPrepopulatesFreshApplicant(): void
|
||||
{
|
||||
$travel = $this->createTravel([1 => 2]);
|
||||
$bookingDto = new BookingDto($travel, 123);
|
||||
$bookingDto->roomSelections = [$this->createRoomSelection(1, 1)];
|
||||
$bookingDto->participants = [new ParticipantDto()];
|
||||
|
||||
$user = $this->createMock(UserInterface::class);
|
||||
$callbackCalled = false;
|
||||
|
||||
$this->service->ensureCorrectNumberOfParticipants(
|
||||
$bookingDto,
|
||||
$user,
|
||||
function (UserInterface $userArg, ParticipantDto $participant) use (&$callbackCalled): ParticipantDto {
|
||||
$callbackCalled = true;
|
||||
$participant->firstName = 'Alex';
|
||||
|
||||
return $participant;
|
||||
}
|
||||
);
|
||||
|
||||
$this->assertTrue($callbackCalled);
|
||||
$this->assertSame('Alex', $bookingDto->participants[0]->firstName);
|
||||
}
|
||||
|
||||
private function createTravel(array $roomCapacities): Travel
|
||||
{
|
||||
$travel = new Travel();
|
||||
|
||||
Reference in New Issue
Block a user