feat: offer non-travelling applicant choice only on selected travels
This commit is contained in:
1 parent
5b75938c73
commit
b958d1a371
9 files changed
+320
-26
No files matched your search
@@ -5,10 +5,13 @@ declare(strict_types=1);
|
||||
namespace App\Tests\Controller\Booking\Create;
|
||||
|
||||
use App\BusProNet\Constants;
|
||||
use App\BusProNet\Model\CrmSelection;
|
||||
use App\BusProNet\Model\CrmSelectionGroup;
|
||||
use App\BusProNet\Model\Room;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Controller\Booking\Create\Step2Controller;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Form\Model\RoomSelectionDto;
|
||||
use App\Model\RoomSelectionAdjustment;
|
||||
use App\Service\BookingConfigurator;
|
||||
@@ -181,6 +184,63 @@ class Step2ControllerTest extends TestCase
|
||||
$this->assertCount(6, $bookingDto->participants, 'Two rooms for three people each yield six participants');
|
||||
}
|
||||
|
||||
public function testEndsASplitTheTravelDateDoesNotOffer(): void
|
||||
{
|
||||
$bookingDto = $this->createSplitBookingDto($this->createTravel([$this->createRoom(1409, 'Einzelzimmer', minPax: 1)]));
|
||||
$applicant = $bookingDto->applicant;
|
||||
|
||||
$controller = $this->createControllerForFullRun($bookingDto);
|
||||
$controller->index(Request::create('/bookings/create/participants', 'GET'));
|
||||
|
||||
$this->assertTrue($bookingDto->applicantTravels);
|
||||
$this->assertNull($bookingDto->applicant);
|
||||
$this->assertSame($applicant, $bookingDto->participants[0]);
|
||||
}
|
||||
|
||||
public function testKeepsASplitTheTravelDateOffers(): void
|
||||
{
|
||||
$travel = $this->createTravel([$this->createRoom(1409, 'Einzelzimmer', minPax: 1)]);
|
||||
$selection = new CrmSelection();
|
||||
$selection->id = 1488;
|
||||
$group = new CrmSelectionGroup();
|
||||
$group->id = 10;
|
||||
$group->selections = [$selection];
|
||||
$travel->selectionGroups = [10 => $group];
|
||||
|
||||
$bookingDto = $this->createSplitBookingDto($travel);
|
||||
$applicant = $bookingDto->applicant;
|
||||
|
||||
$controller = $this->createControllerForFullRun($bookingDto);
|
||||
$controller->index(Request::create('/bookings/create/participants', 'GET'));
|
||||
|
||||
$this->assertFalse($bookingDto->applicantTravels);
|
||||
$this->assertSame($applicant, $bookingDto->applicant);
|
||||
$this->assertNotSame($applicant, $bookingDto->participants[0]);
|
||||
}
|
||||
|
||||
private function createSplitBookingDto(Travel $travel): BookingDto
|
||||
{
|
||||
$bookingDto = $this->createBookingDto($travel);
|
||||
$bookingDto->roomSelections = [
|
||||
1409 => $this->createRoomSelection(1409, 'Einzelzimmer', quantity: 1, capacity: 1),
|
||||
];
|
||||
$bookingDto->applicantTravels = false;
|
||||
$bookingDto->applicant = new ParticipantDto();
|
||||
|
||||
return $bookingDto;
|
||||
}
|
||||
|
||||
private function createControllerForFullRun(BookingDto $bookingDto): TestableStep2Controller
|
||||
{
|
||||
$bookingService = $this->createStub(BookingConfigurator::class);
|
||||
$bookingService->method('reconcileRoomSelections')->willReturn([]);
|
||||
|
||||
$bookingSessionService = $this->createStub(BookingSessionManager::class);
|
||||
$bookingSessionService->method('getOrCreateBookingCreateDto')->willReturn($bookingDto);
|
||||
|
||||
return $this->createController($bookingService, $bookingSessionService, $this->createStub(LoggerInterface::class));
|
||||
}
|
||||
|
||||
private function createController(
|
||||
BookingConfigurator $bookingService,
|
||||
BookingSessionManager $bookingSessionService,
|
||||
|
||||
Reference in new issue
Block a user