feat: upgrade phpunit to 12.5

This commit is contained in:
Björn Fromme
2026-08-31 09:31:00 +02:00
parent 010cfe56b2
commit bfad61f1dd
95 changed files with 1436 additions and 1224 deletions
@@ -53,8 +53,8 @@ class IndexControllerTest extends TestCase
private function makeController(): TestableAccommodationIndexController
{
return new TestableAccommodationIndexController(
$this->createMock(AccommodationBookingService::class),
$this->createMock(AccommodationSessionManager::class),
$this->createStub(AccommodationBookingService::class),
$this->createStub(AccommodationSessionManager::class),
);
}
}
@@ -106,20 +106,20 @@ class Step1CalendarDataTest extends TestCase
string $dateFrom,
string $dateTo,
): array {
$snapshotReader = $this->createMock(ContingentSnapshotReader::class);
$snapshotReader = $this->createStub(ContingentSnapshotReader::class);
$snapshotReader->method('statusesFor')->willReturn($statuses);
$priceRepository = $this->createMock(AccommodationPriceRepository::class);
$priceRepository = $this->createStub(AccommodationPriceRepository::class);
$priceRepository->method('findByHotelCodeAndDateRange')->willReturn($prices);
$controller = new Step1Controller(
$this->createMock(AccommodationBookingService::class),
$this->createMock(AccommodationSessionManager::class),
$this->createStub(AccommodationBookingService::class),
$this->createStub(AccommodationSessionManager::class),
$priceRepository,
new PriceTimelineBuilder(),
$snapshotReader,
$this->createMock(CalendarGridBuilder::class),
$this->createMock(GroupsPriceCalculator::class),
$this->createStub(CalendarGridBuilder::class),
$this->createStub(GroupsPriceCalculator::class),
new AccommodationPriceCoverage($priceRepository),
);
@@ -88,7 +88,7 @@ class Step1ControllerTest extends TestCase
$sessionManager = new AccommodationSessionManager();
$sessionManager->save($request, $dto);
$bookingService = $this->createMock(AccommodationBookingService::class);
$bookingService = $this->createStub(AccommodationBookingService::class);
$bookingService
->method('applyDates')
->willThrowException(new \InvalidArgumentException('Ungültiges Datumsformat. Erwartet: YYYY-MM-DD.'));
@@ -105,14 +105,14 @@ class Step1ControllerTest extends TestCase
AccommodationBookingService $bookingService,
AccommodationSessionManager $sessionManager,
): TestableAccommodationStep1Controller {
$priceRepository = $this->createMock(AccommodationPriceRepository::class);
$priceRepository = $this->createStub(AccommodationPriceRepository::class);
return new TestableAccommodationStep1Controller(
$bookingService,
$sessionManager,
$priceRepository,
new PriceTimelineBuilder(),
$this->createMock(ContingentSnapshotReader::class),
$this->createStub(ContingentSnapshotReader::class),
new CalendarGridBuilder(),
new GroupsPriceCalculator(new PriceTimelineBuilder(), ['runningCostsEur' => 0, 'runningCostsChf' => 0, 'undersubscription30Eur' => 0, 'undersubscription30Chf' => 0, 'undersubscription40Eur' => 0, 'undersubscription40Chf' => 0]),
new AccommodationPriceCoverage($priceRepository),
@@ -38,7 +38,7 @@ class Step2ControllerTest extends TestCase
$sessionManager = new AccommodationSessionManager();
$sessionManager->save($request, $dto);
$form = $this->createMock(FormInterface::class);
$form = $this->createStub(FormInterface::class);
$form
->method('handleRequest')
->willReturnCallback(function () use ($dto, $form): FormInterface {
@@ -156,7 +156,7 @@ class Step3ControllerTest extends TestCase
private function createFormMock(bool $submitted, bool $valid): FormInterface
{
$form = $this->createMock(FormInterface::class);
$form = $this->createStub(FormInterface::class);
$form->method('handleRequest')->willReturnSelf();
$form->method('isSubmitted')->willReturn($submitted);
$form->method('isValid')->willReturn($valid);
@@ -50,7 +50,7 @@ class Step4ControllerTest extends TestCase
'ungroupedAdditionalServices' => [],
]);
$controller = new TestableStep4Controller($bookingService, $sessionManager, $this->createMock(FormInterface::class));
$controller = new TestableStep4Controller($bookingService, $sessionManager, $this->createStub(FormInterface::class));
$response = $controller->index($request);
@@ -73,9 +73,9 @@ class Step4ControllerTest extends TestCase
$sessionManager->save($request, $dto);
$controller = new TestableStep4Controller(
$this->createMock(AccommodationBookingService::class),
$this->createStub(AccommodationBookingService::class),
$sessionManager,
$this->createMock(FormInterface::class),
$this->createStub(FormInterface::class),
);
$response = $controller->index($request);
@@ -115,7 +115,7 @@ class Step4ControllerTest extends TestCase
$bookingService->method('loadPrices')->willReturn([]);
$bookingService->expects(self::once())->method('finalizeBooking')->willReturn($booking);
$inquiryForm = $this->createMock(FormInterface::class);
$inquiryForm = $this->createStub(FormInterface::class);
$inquiryForm->method('handleRequest')->willReturnSelf();
$inquiryForm->method('isSubmitted')->willReturn(true);
$inquiryForm->method('isValid')->willReturn(true);
@@ -158,7 +158,7 @@ class Step4ControllerTest extends TestCase
]);
$bookingService->expects(self::never())->method('finalizeBooking');
$inquiryForm = $this->createMock(FormInterface::class);
$inquiryForm = $this->createStub(FormInterface::class);
$inquiryForm->method('handleRequest')->willReturnSelf();
$inquiryForm->method('isSubmitted')->willReturn(true);
$inquiryForm->method('isValid')->willReturn(false);
@@ -184,9 +184,9 @@ class Step4ControllerTest extends TestCase
$sessionManager->save($request, $dto);
$controller = new TestableStep4Controller(
$this->createMock(AccommodationBookingService::class),
$this->createStub(AccommodationBookingService::class),
$sessionManager,
$this->createMock(FormInterface::class),
$this->createStub(FormInterface::class),
);
$response = $controller->confirmInquiry($request);
@@ -209,9 +209,9 @@ class Step4ControllerTest extends TestCase
$sessionManager->save($request, $dto);
$controller = new TestableStep4Controller(
$this->createMock(AccommodationBookingService::class),
$this->createStub(AccommodationBookingService::class),
$sessionManager,
$this->createMock(FormInterface::class),
$this->createStub(FormInterface::class),
);
$response = $controller->confirmInquiry($request);
@@ -242,7 +242,7 @@ class Step4ControllerTest extends TestCase
$bookingService->method('loadAccommodation')->with(1)->willReturn($accommodation);
$bookingService->expects(self::never())->method('finalizeBooking');
$confirmationForm = $this->createMock(FormInterface::class);
$confirmationForm = $this->createStub(FormInterface::class);
$confirmationForm->method('handleRequest')->willReturnSelf();
$confirmationForm->method('isSubmitted')->willReturn(false);
@@ -288,7 +288,7 @@ class Step4ControllerTest extends TestCase
$bookingService->method('loadPrices')->willReturn([]);
$bookingService->expects(self::once())->method('finalizeBooking')->willReturn($booking);
$confirmationForm = $this->createMock(FormInterface::class);
$confirmationForm = $this->createStub(FormInterface::class);
$confirmationForm->method('handleRequest')->willReturnSelf();
$confirmationForm->method('isSubmitted')->willReturn(true);
$confirmationForm->method('isValid')->willReturn(true);
@@ -324,7 +324,7 @@ class Step4ControllerTest extends TestCase
$bookingService->method('loadAccommodation')->with(1)->willReturn($accommodation);
$bookingService->expects(self::never())->method('finalizeBooking');
$confirmationForm = $this->createMock(FormInterface::class);
$confirmationForm = $this->createStub(FormInterface::class);
$confirmationForm->method('handleRequest')->willReturnSelf();
$confirmationForm->method('isSubmitted')->willReturn(true);
$confirmationForm->method('isValid')->willReturn(false);
@@ -14,6 +14,7 @@ use App\Service\AccommodationBookingBreakdownCalculator;
use App\Service\AccommodationBookingLinkSigner;
use App\Service\AccommodationBookingService;
use App\Service\AccommodationTermsUrlProvider;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
@@ -39,8 +40,8 @@ class IndexControllerTest extends TestCase
$controller = new TestableOfferController(
$bookingRepository,
$linkSigner,
$this->createMock(AccommodationBookingBreakdownCalculator::class),
$this->createMock(AccommodationBookingService::class),
$this->createStub(AccommodationBookingBreakdownCalculator::class),
$this->createStub(AccommodationBookingService::class),
);
$response = $controller->access($booking->getUuid(), Request::create('/groups/booking/offer/'.$booking->getUuid()));
@@ -53,7 +54,7 @@ class IndexControllerTest extends TestCase
{
$booking = new AccommodationBooking();
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
$bookingRepository = $this->createStub(AccommodationBookingRepository::class);
$bookingRepository->method('findOneBy')->willReturn($booking);
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
@@ -63,8 +64,8 @@ class IndexControllerTest extends TestCase
$controller = new TestableOfferController(
$bookingRepository,
$linkSigner,
$this->createMock(AccommodationBookingBreakdownCalculator::class),
$this->createMock(AccommodationBookingService::class),
$this->createStub(AccommodationBookingBreakdownCalculator::class),
$this->createStub(AccommodationBookingService::class),
);
$response = $controller->access($booking->getUuid(), Request::create('/groups/booking/offer/'.$booking->getUuid()));
@@ -75,7 +76,7 @@ class IndexControllerTest extends TestCase
public function testAccessRendersUnavailableForUnknownUuid(): void
{
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
$bookingRepository = $this->createStub(AccommodationBookingRepository::class);
$bookingRepository->method('findOneBy')->willReturn(null);
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
@@ -84,8 +85,8 @@ class IndexControllerTest extends TestCase
$controller = new TestableOfferController(
$bookingRepository,
$linkSigner,
$this->createMock(AccommodationBookingBreakdownCalculator::class),
$this->createMock(AccommodationBookingService::class),
$this->createStub(AccommodationBookingBreakdownCalculator::class),
$this->createStub(AccommodationBookingService::class),
);
$response = $controller->access('unknown-uuid', Request::create('/groups/booking/offer/unknown-uuid'));
@@ -94,15 +95,13 @@ class IndexControllerTest extends TestCase
self::assertSame('groups/offer/unavailable.html.twig', $controller->renderedView);
}
/**
* @dataProvider statusesTheCustomerMustNotSee
*/
#[DataProvider('statusesTheCustomerMustNotSee')]
public function testAccessRendersUnavailableForABookingThatIsNotOfferedYet(AccommodationBookingStatus $status): void
{
$booking = new AccommodationBooking();
$booking->setStatus($status);
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
$bookingRepository = $this->createStub(AccommodationBookingRepository::class);
$bookingRepository->method('findOneBy')->willReturn($booking);
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
@@ -112,8 +111,8 @@ class IndexControllerTest extends TestCase
$controller = new TestableOfferController(
$bookingRepository,
$linkSigner,
$this->createMock(AccommodationBookingBreakdownCalculator::class),
$this->createMock(AccommodationBookingService::class),
$this->createStub(AccommodationBookingBreakdownCalculator::class),
$this->createStub(AccommodationBookingService::class),
);
$response = $controller->access($booking->getUuid(), Request::create('/groups/booking/offer/'.$booking->getUuid()));
@@ -137,19 +136,18 @@ class IndexControllerTest extends TestCase
/**
* The status is re-read on every view, so an authorized session is no free pass: a
* booking pushed back into Entwurf stops showing the offer from that moment on.
*
* @dataProvider statusesTheCustomerMustNotSee
*/
#[DataProvider('statusesTheCustomerMustNotSee')]
public function testViewRendersUnavailableForABookingTheCustomerMustNotSee(AccommodationBookingStatus $status): void
{
$booking = new AccommodationBooking();
$booking->setStatus($status);
$booking->setAccommodation(new Accommodation());
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
$bookingRepository = $this->createStub(AccommodationBookingRepository::class);
$bookingRepository->method('findOneBy')->willReturn($booking);
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
$linkSigner = $this->createStub(AccommodationBookingLinkSigner::class);
$linkSigner->method('isSessionAuthorized')->willReturn(true);
$breakdownCalculator = $this->createMock(AccommodationBookingBreakdownCalculator::class);
@@ -159,7 +157,7 @@ class IndexControllerTest extends TestCase
$bookingRepository,
$linkSigner,
$breakdownCalculator,
$this->createMock(AccommodationBookingService::class),
$this->createStub(AccommodationBookingService::class),
);
$request = Request::create('/groups/booking/offer/'.$booking->getUuid().'/view');
@@ -179,7 +177,7 @@ class IndexControllerTest extends TestCase
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
$bookingRepository->method('findOneBy')->with(['uuid' => $booking->getUuid()])->willReturn($booking);
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
$linkSigner = $this->createStub(AccommodationBookingLinkSigner::class);
$linkSigner->method('isSessionAuthorized')->willReturn(true);
$breakdownCalculator = $this->createMock(AccommodationBookingBreakdownCalculator::class);
@@ -207,17 +205,17 @@ class IndexControllerTest extends TestCase
{
$booking = new AccommodationBooking();
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
$bookingRepository = $this->createStub(AccommodationBookingRepository::class);
$bookingRepository->method('findOneBy')->willReturn($booking);
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
$linkSigner = $this->createStub(AccommodationBookingLinkSigner::class);
$linkSigner->method('isSessionAuthorized')->willReturn(false);
$controller = new TestableOfferController(
$bookingRepository,
$linkSigner,
$this->createMock(AccommodationBookingBreakdownCalculator::class),
$this->createMock(AccommodationBookingService::class),
$this->createStub(AccommodationBookingBreakdownCalculator::class),
$this->createStub(AccommodationBookingService::class),
);
$response = $controller->view($booking->getUuid(), Request::create('/groups/booking/offer/'.$booking->getUuid().'/view'));
@@ -235,18 +233,18 @@ class IndexControllerTest extends TestCase
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
$bookingRepository->method('findOneBy')->with(['uuid' => $booking->getUuid()])->willReturn($booking);
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
$linkSigner = $this->createStub(AccommodationBookingLinkSigner::class);
$linkSigner->method('isSessionAuthorized')->willReturn(true);
$confirmationForm = $this->createMock(FormInterface::class);
$confirmationForm = $this->createStub(FormInterface::class);
$confirmationForm->method('handleRequest')->willReturnSelf();
$confirmationForm->method('isSubmitted')->willReturn(false);
$controller = new TestableOfferController(
$bookingRepository,
$linkSigner,
$this->createMock(AccommodationBookingBreakdownCalculator::class),
$this->createMock(AccommodationBookingService::class),
$this->createStub(AccommodationBookingBreakdownCalculator::class),
$this->createStub(AccommodationBookingService::class),
$confirmationForm,
);
@@ -268,16 +266,16 @@ class IndexControllerTest extends TestCase
$booking->setStatus(AccommodationBookingStatus::Open);
$booking->setRemarks('Bitte Zimmer im EG');
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
$bookingRepository = $this->createStub(AccommodationBookingRepository::class);
$bookingRepository->method('findOneBy')->willReturn($booking);
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
$linkSigner = $this->createStub(AccommodationBookingLinkSigner::class);
$linkSigner->method('isSessionAuthorized')->willReturn(true);
$bookingService = $this->createMock(AccommodationBookingService::class);
$bookingService->expects(self::once())->method('acceptBooking')->with($booking, 'Bitte Zimmer im EG');
$confirmationForm = $this->createMock(FormInterface::class);
$confirmationForm = $this->createStub(FormInterface::class);
$confirmationForm->method('handleRequest')->willReturnSelf();
$confirmationForm->method('isSubmitted')->willReturn(true);
$confirmationForm->method('isValid')->willReturn(true);
@@ -285,7 +283,7 @@ class IndexControllerTest extends TestCase
$controller = new TestableOfferController(
$bookingRepository,
$linkSigner,
$this->createMock(AccommodationBookingBreakdownCalculator::class),
$this->createStub(AccommodationBookingBreakdownCalculator::class),
$bookingService,
$confirmationForm,
);
@@ -303,17 +301,17 @@ class IndexControllerTest extends TestCase
$booking = new AccommodationBooking();
$booking->setStatus(AccommodationBookingStatus::Open);
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
$bookingRepository = $this->createStub(AccommodationBookingRepository::class);
$bookingRepository->method('findOneBy')->willReturn($booking);
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
$linkSigner = $this->createStub(AccommodationBookingLinkSigner::class);
$linkSigner->method('isSessionAuthorized')->willReturn(true);
$bookingService = $this->createMock(AccommodationBookingService::class);
// No remark on the booking and none submitted: the empty string clears rather than keeps.
$bookingService->expects(self::once())->method('acceptBooking')->with($booking, '');
$confirmationForm = $this->createMock(FormInterface::class);
$confirmationForm = $this->createStub(FormInterface::class);
$confirmationForm->method('handleRequest')->willReturnSelf();
$confirmationForm->method('isSubmitted')->willReturn(true);
$confirmationForm->method('isValid')->willReturn(true);
@@ -321,7 +319,7 @@ class IndexControllerTest extends TestCase
$controller = new TestableOfferController(
$bookingRepository,
$linkSigner,
$this->createMock(AccommodationBookingBreakdownCalculator::class),
$this->createStub(AccommodationBookingBreakdownCalculator::class),
$bookingService,
$confirmationForm,
);
@@ -339,16 +337,16 @@ class IndexControllerTest extends TestCase
$booking = new AccommodationBooking();
$booking->setStatus(AccommodationBookingStatus::Open);
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
$bookingRepository = $this->createStub(AccommodationBookingRepository::class);
$bookingRepository->method('findOneBy')->willReturn($booking);
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
$linkSigner = $this->createStub(AccommodationBookingLinkSigner::class);
$linkSigner->method('isSessionAuthorized')->willReturn(true);
$bookingService = $this->createMock(AccommodationBookingService::class);
$bookingService->expects(self::never())->method('acceptBooking');
$confirmationForm = $this->createMock(FormInterface::class);
$confirmationForm = $this->createStub(FormInterface::class);
$confirmationForm->method('handleRequest')->willReturnSelf();
$confirmationForm->method('isSubmitted')->willReturn(true);
$confirmationForm->method('isValid')->willReturn(false);
@@ -356,7 +354,7 @@ class IndexControllerTest extends TestCase
$controller = new TestableOfferController(
$bookingRepository,
$linkSigner,
$this->createMock(AccommodationBookingBreakdownCalculator::class),
$this->createStub(AccommodationBookingBreakdownCalculator::class),
$bookingService,
$confirmationForm,
);
@@ -373,17 +371,17 @@ class IndexControllerTest extends TestCase
$booking = new AccommodationBooking();
$booking->setStatus(AccommodationBookingStatus::Received);
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
$bookingRepository = $this->createStub(AccommodationBookingRepository::class);
$bookingRepository->method('findOneBy')->willReturn($booking);
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
$linkSigner = $this->createStub(AccommodationBookingLinkSigner::class);
$linkSigner->method('isSessionAuthorized')->willReturn(true);
$controller = new TestableOfferController(
$bookingRepository,
$linkSigner,
$this->createMock(AccommodationBookingBreakdownCalculator::class),
$this->createMock(AccommodationBookingService::class),
$this->createStub(AccommodationBookingBreakdownCalculator::class),
$this->createStub(AccommodationBookingService::class),
);
$response = $controller->confirm($booking->getUuid(), Request::create('/groups/booking/offer/'.$booking->getUuid().'/confirm'));
@@ -395,17 +393,17 @@ class IndexControllerTest extends TestCase
{
$booking = new AccommodationBooking();
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
$bookingRepository = $this->createStub(AccommodationBookingRepository::class);
$bookingRepository->method('findOneBy')->willReturn($booking);
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
$linkSigner = $this->createStub(AccommodationBookingLinkSigner::class);
$linkSigner->method('isSessionAuthorized')->willReturn(false);
$controller = new TestableOfferController(
$bookingRepository,
$linkSigner,
$this->createMock(AccommodationBookingBreakdownCalculator::class),
$this->createMock(AccommodationBookingService::class),
$this->createStub(AccommodationBookingBreakdownCalculator::class),
$this->createStub(AccommodationBookingService::class),
);
$response = $controller->confirm($booking->getUuid(), Request::create('/groups/booking/offer/'.$booking->getUuid().'/confirm'));
@@ -415,7 +413,7 @@ class IndexControllerTest extends TestCase
public function testConfirmRedirectsForUnknownUuid(): void
{
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
$bookingRepository = $this->createStub(AccommodationBookingRepository::class);
$bookingRepository->method('findOneBy')->willReturn(null);
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
@@ -424,8 +422,8 @@ class IndexControllerTest extends TestCase
$controller = new TestableOfferController(
$bookingRepository,
$linkSigner,
$this->createMock(AccommodationBookingBreakdownCalculator::class),
$this->createMock(AccommodationBookingService::class),
$this->createStub(AccommodationBookingBreakdownCalculator::class),
$this->createStub(AccommodationBookingService::class),
);
$response = $controller->confirm('unknown-uuid', Request::create('/groups/booking/offer/unknown-uuid/confirm'));