feat: groups price calculator admin crud, booking/offer flow and api
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Controller\Accommodation;
|
||||
|
||||
use App\Controller\Groups\IndexController;
|
||||
use App\Service\AccommodationBookingService;
|
||||
use App\Service\AccommodationSessionManager;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Session\Session;
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
||||
|
||||
class IndexControllerTest extends TestCase
|
||||
{
|
||||
public function testSuccessRendersAndConsumesFlashOnFirstLoad(): void
|
||||
{
|
||||
$session = new Session(new MockArraySessionStorage());
|
||||
$session->getFlashBag()->add('groups_booking_result', 'booking');
|
||||
|
||||
$request = Request::create('/groups/booking/success', 'GET');
|
||||
$request->setSession($session);
|
||||
|
||||
$controller = $this->makeController();
|
||||
|
||||
$response = $controller->success($request);
|
||||
|
||||
self::assertSame(200, $response->getStatusCode());
|
||||
self::assertSame('groups/booking/success.html.twig', $controller->renderedView);
|
||||
self::assertSame('booking', $controller->renderedParameters['resultType']);
|
||||
// The flash is read-once: a second read on the same request returns nothing.
|
||||
self::assertSame([], $session->getFlashBag()->get('groups_booking_result'));
|
||||
}
|
||||
|
||||
public function testSuccessRedirectsToLoginWhenFlashIsMissing(): void
|
||||
{
|
||||
$session = new Session(new MockArraySessionStorage());
|
||||
|
||||
$request = Request::create('/groups/booking/success', 'GET');
|
||||
$request->setSession($session);
|
||||
|
||||
$controller = $this->makeController();
|
||||
|
||||
$response = $controller->success($request);
|
||||
|
||||
self::assertInstanceOf(RedirectResponse::class, $response);
|
||||
self::assertSame('/app_login', $response->headers->get('Location'));
|
||||
}
|
||||
|
||||
private function makeController(): TestableAccommodationIndexController
|
||||
{
|
||||
return new TestableAccommodationIndexController(
|
||||
$this->createMock(AccommodationBookingService::class),
|
||||
$this->createMock(AccommodationSessionManager::class),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
final class TestableAccommodationIndexController extends IndexController
|
||||
{
|
||||
/**
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
public array $renderedParameters = [];
|
||||
|
||||
public string $renderedView = '';
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $parameters
|
||||
*/
|
||||
protected function redirectToRoute(string $route, array $parameters = [], int $status = 302): RedirectResponse
|
||||
{
|
||||
return new RedirectResponse('/'.$route, $status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $parameters
|
||||
*/
|
||||
protected function render(string $view, array $parameters = [], ?Response $response = null): Response
|
||||
{
|
||||
$this->renderedView = $view;
|
||||
$this->renderedParameters = $parameters;
|
||||
|
||||
return new Response('ok');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Controller\Accommodation;
|
||||
|
||||
use App\BpnConnect\ContingentsClient;
|
||||
use App\Controller\Groups\Step1Controller;
|
||||
use App\Entity\Groups\Accommodation;
|
||||
use App\Form\Model\AccommodationBookingDto;
|
||||
use App\Repository\Groups\AccommodationPriceRepository;
|
||||
use App\Service\AccommodationBookingService;
|
||||
use App\Service\AccommodationSessionManager;
|
||||
use App\Service\CalendarGridBuilder;
|
||||
use App\Service\GroupsPriceCalculator;
|
||||
use App\Service\PriceTimelineBuilder;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Session\Session;
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
||||
use Symfony\Contracts\Cache\CacheInterface;
|
||||
|
||||
class Step1ControllerTest extends TestCase
|
||||
{
|
||||
public function testPostWithValidDatesUpdatesSessionAndRedirects(): void
|
||||
{
|
||||
$dto = new AccommodationBookingDto();
|
||||
$dto->accommodationId = 1;
|
||||
|
||||
$session = new Session(new MockArraySessionStorage());
|
||||
$request = Request::create('/groups/booking/step-1', 'POST', [
|
||||
'date_from' => '2026-08-03',
|
||||
'date_to' => '2026-08-07',
|
||||
]);
|
||||
$request->setSession($session);
|
||||
|
||||
$sessionManager = new AccommodationSessionManager();
|
||||
$sessionManager->save($request, $dto);
|
||||
|
||||
$accommodation = (new Accommodation())
|
||||
->setName('Hotel')
|
||||
->setCalendarCode('HOTEL')
|
||||
->setMaxAdolescentAge(17);
|
||||
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService
|
||||
->method('applyDates')
|
||||
->willReturnCallback(static function (AccommodationBookingDto $dto): void {
|
||||
$dto->dateFrom = new \DateTimeImmutable('2026-08-03');
|
||||
$dto->dateTo = new \DateTimeImmutable('2026-08-07');
|
||||
});
|
||||
$bookingService
|
||||
->method('loadAccommodation')
|
||||
->with(1)
|
||||
->willReturn($accommodation);
|
||||
$bookingService
|
||||
->method('computeInitialPaxCount')
|
||||
->willReturn(4);
|
||||
|
||||
$controller = $this->makeController($bookingService, $sessionManager);
|
||||
|
||||
$response = $controller->index($request);
|
||||
|
||||
self::assertInstanceOf(RedirectResponse::class, $response);
|
||||
self::assertSame('/app_groups_booking_step_2', $response->headers->get('Location'));
|
||||
|
||||
$savedDto = $sessionManager->getOrFail($request);
|
||||
self::assertSame(2, $savedDto->currentStep);
|
||||
self::assertSame(4, $savedDto->paxCount);
|
||||
self::assertNull($savedDto->selectedBoardServiceId);
|
||||
self::assertSame([], $savedDto->selectedAdditionalServiceIds);
|
||||
}
|
||||
|
||||
public function testPostWithInvalidDatesRedirectsBackWithFlash(): void
|
||||
{
|
||||
$dto = new AccommodationBookingDto();
|
||||
$dto->accommodationId = 1;
|
||||
|
||||
$session = new Session(new MockArraySessionStorage());
|
||||
$request = Request::create('/groups/booking/step-1', 'POST', [
|
||||
'date_from' => 'not-a-date',
|
||||
'date_to' => '2026-08-07',
|
||||
]);
|
||||
$request->setSession($session);
|
||||
|
||||
$sessionManager = new AccommodationSessionManager();
|
||||
$sessionManager->save($request, $dto);
|
||||
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService
|
||||
->method('applyDates')
|
||||
->willThrowException(new \InvalidArgumentException('Ungültiges Datumsformat. Erwartet: YYYY-MM-DD.'));
|
||||
|
||||
$controller = $this->makeController($bookingService, $sessionManager);
|
||||
|
||||
$response = $controller->index($request);
|
||||
|
||||
self::assertInstanceOf(RedirectResponse::class, $response);
|
||||
self::assertSame('/app_groups_booking_step_1', $response->headers->get('Location'));
|
||||
}
|
||||
|
||||
private function makeController(
|
||||
AccommodationBookingService $bookingService,
|
||||
AccommodationSessionManager $sessionManager,
|
||||
): TestableAccommodationStep1Controller {
|
||||
return new TestableAccommodationStep1Controller(
|
||||
$bookingService,
|
||||
$sessionManager,
|
||||
$this->createMock(ContingentsClient::class),
|
||||
$this->createMock(AccommodationPriceRepository::class),
|
||||
new PriceTimelineBuilder(),
|
||||
$this->createMock(CacheInterface::class),
|
||||
new CalendarGridBuilder(),
|
||||
new GroupsPriceCalculator(new PriceTimelineBuilder(), ['runningCostsEur' => 0, 'runningCostsChf' => 0, 'undersubscription30Eur' => 0, 'undersubscription30Chf' => 0, 'undersubscription40Eur' => 0, 'undersubscription40Chf' => 0]),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
final class TestableAccommodationStep1Controller extends Step1Controller
|
||||
{
|
||||
public function __construct(
|
||||
AccommodationBookingService $bookingService,
|
||||
AccommodationSessionManager $sessionManager,
|
||||
ContingentsClient $contingentsClient,
|
||||
AccommodationPriceRepository $priceRepository,
|
||||
PriceTimelineBuilder $priceTimelineBuilder,
|
||||
CacheInterface $cache,
|
||||
CalendarGridBuilder $calendarGridBuilder,
|
||||
GroupsPriceCalculator $priceCalculator,
|
||||
) {
|
||||
parent::__construct(
|
||||
$bookingService,
|
||||
$sessionManager,
|
||||
$contingentsClient,
|
||||
$priceRepository,
|
||||
$priceTimelineBuilder,
|
||||
$cache,
|
||||
$calendarGridBuilder,
|
||||
$priceCalculator,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $parameters
|
||||
*/
|
||||
protected function redirectToRoute(string $route, array $parameters = [], int $status = 302): RedirectResponse
|
||||
{
|
||||
return new RedirectResponse('/'.$route, $status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $parameters
|
||||
*/
|
||||
protected function render(string $view, array $parameters = [], ?Response $response = null): Response
|
||||
{
|
||||
throw new \LogicException('Render should not be called in this test.');
|
||||
}
|
||||
|
||||
protected function addFlash(string $type, mixed $message): void
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Controller\Accommodation;
|
||||
|
||||
use App\Controller\Groups\Step2Controller;
|
||||
use App\Entity\Groups\Accommodation;
|
||||
use App\Form\Model\AccommodationBookingDto;
|
||||
use App\Model\InquiryStatus;
|
||||
use App\Service\AccommodationBookingService;
|
||||
use App\Service\AccommodationSessionManager;
|
||||
use App\Service\GroupsPriceCalculator;
|
||||
use App\Service\PriceTimelineBuilder;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Session\Session;
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
||||
|
||||
class Step2ControllerTest extends TestCase
|
||||
{
|
||||
public function testSubmitRecomputesBookingModeAfterFormBinding(): void
|
||||
{
|
||||
$dto = new AccommodationBookingDto();
|
||||
$dto->currentStep = 2;
|
||||
$dto->accommodationId = 1;
|
||||
$dto->dateFrom = new \DateTimeImmutable('2026-03-01');
|
||||
$dto->dateTo = new \DateTimeImmutable('2026-03-05');
|
||||
$dto->paxCount = 1;
|
||||
|
||||
$session = new Session(new MockArraySessionStorage());
|
||||
$request = Request::create('/groups/booking/step-2', 'POST');
|
||||
$request->setSession($session);
|
||||
|
||||
$sessionManager = new AccommodationSessionManager();
|
||||
$sessionManager->save($request, $dto);
|
||||
|
||||
$form = $this->createMock(FormInterface::class);
|
||||
$form
|
||||
->method('handleRequest')
|
||||
->willReturnCallback(function () use ($dto, $form): FormInterface {
|
||||
$dto->paxCount = 3;
|
||||
|
||||
return $form;
|
||||
});
|
||||
$form
|
||||
->method('isSubmitted')
|
||||
->willReturn(true);
|
||||
$form
|
||||
->method('isValid')
|
||||
->willReturn(true);
|
||||
|
||||
$accommodation = (new Accommodation())
|
||||
->setName('Hotel')
|
||||
->setCalendarCode('HOTEL')
|
||||
->setMaxAdolescentAge(17);
|
||||
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService
|
||||
->method('loadAccommodation')
|
||||
->with(1)
|
||||
->willReturn($accommodation);
|
||||
$bookingService
|
||||
->method('loadPrices')
|
||||
->with($dto, $accommodation)
|
||||
->willReturn([]);
|
||||
$bookingService
|
||||
->method('loadAvailableServices')
|
||||
->with($dto, $accommodation)
|
||||
->willReturn([
|
||||
'boardServices' => [],
|
||||
'additionalServices' => [],
|
||||
'groupedAdditionalServices' => [],
|
||||
'ungroupedAdditionalServices' => [],
|
||||
]);
|
||||
$bookingService
|
||||
->expects(self::once())
|
||||
->method('computeInquiryStatus')
|
||||
->with(self::callback(static fn (AccommodationBookingDto $submittedDto): bool => 3 === $submittedDto->paxCount), [])
|
||||
->willReturn(new InquiryStatus(true, ['Mindestaufenthalt: 5 Nächte (gebucht: 4)']));
|
||||
|
||||
$controller = new TestableAccommodationStep2Controller(
|
||||
$bookingService,
|
||||
$sessionManager,
|
||||
new GroupsPriceCalculator(new PriceTimelineBuilder(), ['runningCostsEur' => 0, 'runningCostsChf' => 0, 'undersubscription30Eur' => 0, 'undersubscription30Chf' => 0, 'undersubscription40Eur' => 0, 'undersubscription40Chf' => 0]),
|
||||
$form,
|
||||
);
|
||||
|
||||
$response = $controller->index($request);
|
||||
|
||||
self::assertInstanceOf(RedirectResponse::class, $response);
|
||||
self::assertSame('/groups/booking/step-3', $response->headers->get('Location'));
|
||||
self::assertTrue($sessionManager->getOrFail($request)->isInquiry);
|
||||
}
|
||||
}
|
||||
|
||||
final class TestableAccommodationStep2Controller extends Step2Controller
|
||||
{
|
||||
/**
|
||||
* @param FormInterface<mixed> $form
|
||||
*/
|
||||
public function __construct(
|
||||
AccommodationBookingService $bookingService,
|
||||
AccommodationSessionManager $sessionManager,
|
||||
GroupsPriceCalculator $priceCalculator,
|
||||
private readonly FormInterface $form,
|
||||
) {
|
||||
parent::__construct($bookingService, $sessionManager, $priceCalculator);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FormInterface<mixed>
|
||||
*/
|
||||
protected function createForm(string $type, mixed $data = null, array $options = []): FormInterface
|
||||
{
|
||||
return $this->form;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $parameters
|
||||
*/
|
||||
protected function redirectToRoute(string $route, array $parameters = [], int $status = 302): RedirectResponse
|
||||
{
|
||||
return new RedirectResponse('/groups/booking/step-3', $status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $parameters
|
||||
*/
|
||||
protected function render(string $view, array $parameters = [], ?Response $response = null): Response
|
||||
{
|
||||
throw new \LogicException('Render should not be called in this test.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Controller\Accommodation;
|
||||
|
||||
use App\Controller\Groups\Step3Controller;
|
||||
use App\Entity\Groups\Accommodation;
|
||||
use App\Entity\Groups\AdditionalService;
|
||||
use App\Entity\Groups\BoardService;
|
||||
use App\Form\Model\AccommodationBookingDto;
|
||||
use App\Service\AccommodationBookingService;
|
||||
use App\Service\AccommodationSessionManager;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Session\Session;
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
||||
|
||||
class Step3ControllerTest extends TestCase
|
||||
{
|
||||
public function testSummaryReceivesSelectedServiceCatalogs(): void
|
||||
{
|
||||
$dto = new AccommodationBookingDto();
|
||||
$dto->currentStep = 3;
|
||||
$dto->accommodationId = 1;
|
||||
$dto->dateFrom = new \DateTimeImmutable('2026-03-01');
|
||||
$dto->dateTo = new \DateTimeImmutable('2026-03-05');
|
||||
$dto->selectedBoardServiceId = 10;
|
||||
$dto->selectedAdditionalServiceIds = [20];
|
||||
|
||||
$session = new Session(new MockArraySessionStorage());
|
||||
$request = Request::create('/groups/booking/step-3', 'GET');
|
||||
$request->setSession($session);
|
||||
|
||||
$sessionManager = new AccommodationSessionManager();
|
||||
$sessionManager->save($request, $dto);
|
||||
|
||||
$form = $this->createFormMock(submitted: false, valid: false);
|
||||
|
||||
$accommodation = (new Accommodation())
|
||||
->setName('Hotel')
|
||||
->setCalendarCode('HOTEL')
|
||||
->setMaxAdolescentAge(17);
|
||||
|
||||
$boardService = (new BoardService())->setLabel('Halbpension')->setPrice(1000);
|
||||
$additionalService = (new AdditionalService())->setLabel('Skipass')->setPrice(2000);
|
||||
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService
|
||||
->method('loadAccommodation')
|
||||
->with(1)
|
||||
->willReturn($accommodation);
|
||||
$bookingService
|
||||
->expects(self::once())
|
||||
->method('loadAvailableServices')
|
||||
->with($dto, $accommodation)
|
||||
->willReturn([
|
||||
'boardServices' => [$boardService],
|
||||
'additionalServices' => [$additionalService],
|
||||
'groupedAdditionalServices' => [],
|
||||
'ungroupedAdditionalServices' => [$additionalService],
|
||||
]);
|
||||
|
||||
$controller = new TestableAccommodationStep3Controller($bookingService, $sessionManager, $form);
|
||||
|
||||
$response = $controller->index($request);
|
||||
|
||||
self::assertSame(200, $response->getStatusCode());
|
||||
self::assertSame('groups/booking/step_3.html.twig', $controller->renderedView);
|
||||
self::assertSame([$boardService], $controller->renderedParameters['ctx']->boardServices);
|
||||
self::assertSame([$additionalService], $controller->renderedParameters['ctx']->additionalServices);
|
||||
}
|
||||
|
||||
public function testValidSubmitRedirectsToStep4WithoutPersisting(): void
|
||||
{
|
||||
$dto = new AccommodationBookingDto();
|
||||
$dto->currentStep = 3;
|
||||
$dto->accommodationId = 1;
|
||||
$dto->isInquiry = false;
|
||||
|
||||
$session = new Session(new MockArraySessionStorage());
|
||||
$request = Request::create('/groups/booking/step-3', 'POST');
|
||||
$request->setSession($session);
|
||||
|
||||
$sessionManager = new AccommodationSessionManager();
|
||||
$sessionManager->save($request, $dto);
|
||||
|
||||
$form = $this->createFormMock(submitted: true, valid: true);
|
||||
|
||||
$accommodation = (new Accommodation())
|
||||
->setName('Hotel')
|
||||
->setCalendarCode('HOTEL')
|
||||
->setMaxAdolescentAge(17);
|
||||
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->method('loadAccommodation')->with(1)->willReturn($accommodation);
|
||||
$bookingService->method('loadAvailableServices')->willReturn([
|
||||
'boardServices' => [],
|
||||
'additionalServices' => [],
|
||||
'groupedAdditionalServices' => [],
|
||||
'ungroupedAdditionalServices' => [],
|
||||
]);
|
||||
$bookingService->expects(self::never())->method('finalizeBooking');
|
||||
|
||||
$controller = new TestableAccommodationStep3Controller($bookingService, $sessionManager, $form);
|
||||
|
||||
$response = $controller->index($request);
|
||||
|
||||
self::assertInstanceOf(RedirectResponse::class, $response);
|
||||
self::assertSame('/app_groups_booking_step_4', $response->getTargetUrl());
|
||||
self::assertSame(4, $dto->currentStep);
|
||||
self::assertSame($dto, $sessionManager->getDto($request));
|
||||
}
|
||||
|
||||
public function testInvalidSubmitReRendersFormWithErrors(): void
|
||||
{
|
||||
$dto = new AccommodationBookingDto();
|
||||
$dto->currentStep = 3;
|
||||
$dto->accommodationId = 1;
|
||||
|
||||
$session = new Session(new MockArraySessionStorage());
|
||||
$request = Request::create('/groups/booking/step-3', 'POST');
|
||||
$request->setSession($session);
|
||||
|
||||
$sessionManager = new AccommodationSessionManager();
|
||||
$sessionManager->save($request, $dto);
|
||||
|
||||
$form = $this->createFormMock(submitted: true, valid: false);
|
||||
|
||||
$accommodation = (new Accommodation())
|
||||
->setName('Hotel')
|
||||
->setCalendarCode('HOTEL')
|
||||
->setMaxAdolescentAge(17);
|
||||
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->method('loadAccommodation')->with(1)->willReturn($accommodation);
|
||||
$bookingService->method('loadAvailableServices')->willReturn([
|
||||
'boardServices' => [],
|
||||
'additionalServices' => [],
|
||||
'groupedAdditionalServices' => [],
|
||||
'ungroupedAdditionalServices' => [],
|
||||
]);
|
||||
|
||||
$controller = new TestableAccommodationStep3Controller($bookingService, $sessionManager, $form);
|
||||
|
||||
$response = $controller->index($request);
|
||||
|
||||
self::assertSame(200, $response->getStatusCode());
|
||||
self::assertSame('groups/booking/step_3.html.twig', $controller->renderedView);
|
||||
self::assertSame(3, $dto->currentStep);
|
||||
self::assertSame($dto, $sessionManager->getDto($request));
|
||||
}
|
||||
|
||||
private function createFormMock(bool $submitted, bool $valid): FormInterface
|
||||
{
|
||||
$form = $this->createMock(FormInterface::class);
|
||||
$form->method('handleRequest')->willReturnSelf();
|
||||
$form->method('isSubmitted')->willReturn($submitted);
|
||||
$form->method('isValid')->willReturn($valid);
|
||||
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
|
||||
final class TestableAccommodationStep3Controller extends Step3Controller
|
||||
{
|
||||
/**
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
public array $renderedParameters = [];
|
||||
|
||||
public string $renderedView = '';
|
||||
|
||||
public function __construct(
|
||||
AccommodationBookingService $bookingService,
|
||||
AccommodationSessionManager $sessionManager,
|
||||
private readonly FormInterface $form,
|
||||
) {
|
||||
parent::__construct($bookingService, $sessionManager);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FormInterface<mixed>
|
||||
*/
|
||||
protected function createForm(string $type, mixed $data = null, array $options = []): FormInterface
|
||||
{
|
||||
return $this->form;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $parameters
|
||||
*/
|
||||
protected function redirectToRoute(string $route, array $parameters = [], int $status = 302): RedirectResponse
|
||||
{
|
||||
return new RedirectResponse('/'.$route, $status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $parameters
|
||||
*/
|
||||
protected function generateUrl(string $route, array $parameters = [], int $referenceType = 1): string
|
||||
{
|
||||
return '/'.$route;
|
||||
}
|
||||
|
||||
protected function addFlash(string $type, mixed $message): void
|
||||
{
|
||||
// no-op: avoids requiring a full service container in these unit tests
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $parameters
|
||||
*/
|
||||
protected function render(string $view, array $parameters = [], ?Response $response = null): Response
|
||||
{
|
||||
$this->renderedView = $view;
|
||||
$this->renderedParameters = $parameters;
|
||||
|
||||
return new Response('ok');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user