feat: upgrade phpunit to 12.5
This commit is contained in:
@@ -27,7 +27,10 @@ class PersonalDataControllerTest extends TestCase
|
||||
{
|
||||
public function testIndexRendersNewsletterSubscribeCtaWhenNotSubscribed(): void
|
||||
{
|
||||
$controller = $this->createController();
|
||||
$controller = $this->createController(
|
||||
apiClient: $this->createMock(ApiClient::class),
|
||||
newsletterManager: $this->createMock(NewsletterManager::class),
|
||||
);
|
||||
$controller->apiClient
|
||||
->expects(self::once())
|
||||
->method('getPersonalData')
|
||||
@@ -55,7 +58,10 @@ class PersonalDataControllerTest extends TestCase
|
||||
|
||||
public function testIndexStillTracksPendingNewsletterConfirmationWhenSubscribed(): void
|
||||
{
|
||||
$controller = $this->createController();
|
||||
$controller = $this->createController(
|
||||
apiClient: $this->createMock(ApiClient::class),
|
||||
newsletterManager: $this->createMock(NewsletterManager::class),
|
||||
);
|
||||
$controller->apiClient
|
||||
->expects(self::once())
|
||||
->method('getPersonalData')
|
||||
@@ -82,7 +88,10 @@ class PersonalDataControllerTest extends TestCase
|
||||
|
||||
public function testNewsletterActionReturnsHtmxRedirectAndFlash(): void
|
||||
{
|
||||
$controller = $this->createController();
|
||||
$controller = $this->createController(
|
||||
apiClient: $this->createMock(ApiClient::class),
|
||||
newsletterManager: $this->createMock(NewsletterManager::class),
|
||||
);
|
||||
$controller->apiClient
|
||||
->expects(self::once())
|
||||
->method('getPersonalData')
|
||||
@@ -122,7 +131,10 @@ class PersonalDataControllerTest extends TestCase
|
||||
|
||||
public function testNewsletterActionResendsPendingConfirmation(): void
|
||||
{
|
||||
$controller = $this->createController();
|
||||
$controller = $this->createController(
|
||||
apiClient: $this->createMock(ApiClient::class),
|
||||
newsletterManager: $this->createMock(NewsletterManager::class),
|
||||
);
|
||||
$controller->apiClient
|
||||
->expects(self::once())
|
||||
->method('getPersonalData')
|
||||
@@ -173,7 +185,10 @@ class PersonalDataControllerTest extends TestCase
|
||||
*/
|
||||
public function testIndexDoesNotSubmitTheFormWhenPersonalDataCouldNotBeLoaded(): void
|
||||
{
|
||||
$controller = $this->createController();
|
||||
$controller = $this->createController(
|
||||
apiClient: $this->createMock(ApiClient::class),
|
||||
form: $this->createMock(FormInterface::class),
|
||||
);
|
||||
$controller->apiClient
|
||||
->expects(self::once())
|
||||
->method('getPersonalData')
|
||||
@@ -194,20 +209,25 @@ class PersonalDataControllerTest extends TestCase
|
||||
self::assertSame('account/personal_data.html.twig', $controller->renderedView);
|
||||
}
|
||||
|
||||
private function createController(): TestablePersonalDataController
|
||||
{
|
||||
/**
|
||||
* Collaborators default to stubs; a test passes its own mock for whatever it sets
|
||||
* expectations on, and reaches it again through the controller's public property.
|
||||
*/
|
||||
private function createController(
|
||||
?ApiClient $apiClient = null,
|
||||
?NewsletterManager $newsletterManager = null,
|
||||
?FormInterface $form = null,
|
||||
): TestablePersonalDataController {
|
||||
$user = new User('[email protected]');
|
||||
$user->setPassword('secret');
|
||||
|
||||
$apiClient = $this->createMock(ApiClient::class);
|
||||
|
||||
$crypt = $this->createMock(Crypt::class);
|
||||
$crypt
|
||||
->method('decrypt')
|
||||
->with('secret')
|
||||
->willReturn('secret');
|
||||
|
||||
$form = $this->createMock(FormInterface::class);
|
||||
$form ??= $this->createStub(FormInterface::class);
|
||||
$form
|
||||
->method('handleRequest')
|
||||
->willReturnSelf();
|
||||
@@ -216,13 +236,13 @@ class PersonalDataControllerTest extends TestCase
|
||||
->willReturn(false);
|
||||
|
||||
return new TestablePersonalDataController(
|
||||
$apiClient,
|
||||
$apiClient ?? $this->createStub(ApiClient::class),
|
||||
$crypt,
|
||||
$this->createMock(BookingEditDataLoader::class),
|
||||
$this->createMock(ProfileCompletenessChecker::class),
|
||||
$this->createMock(EntityManagerInterface::class),
|
||||
$this->createMock(NewsletterManager::class),
|
||||
$this->createMock(LoggerInterface::class),
|
||||
$this->createStub(BookingEditDataLoader::class),
|
||||
$this->createStub(ProfileCompletenessChecker::class),
|
||||
$this->createStub(EntityManagerInterface::class),
|
||||
$newsletterManager ?? $this->createStub(NewsletterManager::class),
|
||||
$this->createStub(LoggerInterface::class),
|
||||
$user,
|
||||
$form,
|
||||
);
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Entity\Groups\Accommodation;
|
||||
use App\Entity\Groups\AccommodationBooking;
|
||||
use App\Enum\Groups\AccommodationBookingStatus;
|
||||
use App\Service\AccommodationBookingService;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
@@ -34,9 +35,7 @@ class ChangeAccommodationControllerTest extends TestCase
|
||||
self::assertSame('admin/accommodation_booking/modal_change_accommodation.html.twig', $controller->renderedView);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider lockedStatuses
|
||||
*/
|
||||
#[DataProvider('lockedStatuses')]
|
||||
public function testABookingThatHasLeftEntwurfCannotMoveHouse(AccommodationBookingStatus $status): void
|
||||
{
|
||||
// The customer may already be looking at the offer under their access link.
|
||||
@@ -127,7 +126,7 @@ class ChangeAccommodationControllerTest extends TestCase
|
||||
|
||||
private function unsubmittedForm(): FormInterface
|
||||
{
|
||||
$form = $this->createMock(FormInterface::class);
|
||||
$form = $this->createStub(FormInterface::class);
|
||||
$form->method('handleRequest')->willReturn($form);
|
||||
$form->method('isSubmitted')->willReturn(false);
|
||||
|
||||
@@ -136,7 +135,7 @@ class ChangeAccommodationControllerTest extends TestCase
|
||||
|
||||
private function submittedForm(Accommodation $selected): FormInterface
|
||||
{
|
||||
$field = $this->createMock(FormInterface::class);
|
||||
$field = $this->createStub(FormInterface::class);
|
||||
$field->method('getData')->willReturn($selected);
|
||||
|
||||
$form = $this->createMock(FormInterface::class);
|
||||
@@ -154,7 +153,7 @@ class ChangeAccommodationControllerTest extends TestCase
|
||||
): TestableChangeAccommodationController {
|
||||
return new TestableChangeAccommodationController(
|
||||
$bookingService,
|
||||
$this->createMock(LoggerInterface::class),
|
||||
$this->createStub(LoggerInterface::class),
|
||||
$form,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Entity\Groups\AccommodationBooking;
|
||||
use App\Enum\Groups\AccommodationBookingStatus;
|
||||
use App\Message\CreateClickUpBookingTaskMessage;
|
||||
use App\Service\AccommodationBookingService;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@@ -29,7 +30,7 @@ class ConfirmControllerTest extends TestCase
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->expects(self::never())->method('confirmBooking');
|
||||
|
||||
$controller = new TestableConfirmController($bookingService, $this->neverDispatchingBus(), $this->createMock(LoggerInterface::class));
|
||||
$controller = new TestableConfirmController($bookingService, $this->neverDispatchingBus(), $this->createStub(LoggerInterface::class));
|
||||
|
||||
$response = $controller->index($this->receivedBooking(), Request::create('/admin/accommodation-booking/1/confirm'));
|
||||
|
||||
@@ -51,7 +52,7 @@ class ConfirmControllerTest extends TestCase
|
||||
->with(self::isInstanceOf(CreateClickUpBookingTaskMessage::class))
|
||||
->willReturnCallback(static fn (object $message): Envelope => new Envelope($message));
|
||||
|
||||
$controller = new TestableConfirmController($bookingService, $messageBus, $this->createMock(LoggerInterface::class));
|
||||
$controller = new TestableConfirmController($bookingService, $messageBus, $this->createStub(LoggerInterface::class));
|
||||
|
||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/confirm', 'POST'));
|
||||
|
||||
@@ -63,16 +64,14 @@ class ConfirmControllerTest extends TestCase
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->expects(self::never())->method('confirmBooking');
|
||||
|
||||
$controller = new TestableConfirmController($bookingService, $this->neverDispatchingBus(), $this->createMock(LoggerInterface::class), tokenValid: false);
|
||||
$controller = new TestableConfirmController($bookingService, $this->neverDispatchingBus(), $this->createStub(LoggerInterface::class), tokenValid: false);
|
||||
|
||||
$this->expectException(AccessDeniedException::class);
|
||||
|
||||
$controller->index($this->receivedBooking(), Request::create('/admin/accommodation-booking/1/confirm', 'POST'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider nonReceivedStatuses
|
||||
*/
|
||||
#[DataProvider('nonReceivedStatuses')]
|
||||
public function testABookingThatIsNotAwaitingValidationCannotBeConfirmed(AccommodationBookingStatus $status): void
|
||||
{
|
||||
$booking = $this->receivedBooking();
|
||||
@@ -81,7 +80,7 @@ class ConfirmControllerTest extends TestCase
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->expects(self::never())->method('confirmBooking');
|
||||
|
||||
$controller = new TestableConfirmController($bookingService, $this->neverDispatchingBus(), $this->createMock(LoggerInterface::class));
|
||||
$controller = new TestableConfirmController($bookingService, $this->neverDispatchingBus(), $this->createStub(LoggerInterface::class));
|
||||
|
||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/confirm', 'POST'));
|
||||
|
||||
@@ -108,7 +107,7 @@ class ConfirmControllerTest extends TestCase
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->expects(self::never())->method('confirmBooking');
|
||||
|
||||
$controller = new TestableConfirmController($bookingService, $this->neverDispatchingBus(), $this->createMock(LoggerInterface::class));
|
||||
$controller = new TestableConfirmController($bookingService, $this->neverDispatchingBus(), $this->createStub(LoggerInterface::class));
|
||||
|
||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/confirm', 'POST'));
|
||||
|
||||
|
||||
@@ -34,14 +34,14 @@ class CreateControllerTest extends TestCase
|
||||
|
||||
private function buildController(?UserInterface $user): TestableCreateController
|
||||
{
|
||||
$form = $this->createMock(FormInterface::class);
|
||||
$form = $this->createStub(FormInterface::class);
|
||||
$form->method('handleRequest')->willReturn($form);
|
||||
$form->method('isSubmitted')->willReturn(false);
|
||||
|
||||
return new TestableCreateController(
|
||||
$this->createMock(EntityManagerInterface::class),
|
||||
$this->createMock(LoggerInterface::class),
|
||||
$this->createMock(AccommodationBookingService::class),
|
||||
$this->createStub(EntityManagerInterface::class),
|
||||
$this->createStub(LoggerInterface::class),
|
||||
$this->createStub(AccommodationBookingService::class),
|
||||
$form,
|
||||
$user,
|
||||
);
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Entity\Groups\Accommodation;
|
||||
use App\Entity\Groups\AccommodationBooking;
|
||||
use App\Enum\Groups\AccommodationBookingStatus;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -53,9 +54,7 @@ class DeleteControllerTest extends TestCase
|
||||
self::assertSame('success', $controller->flashes[0]['type']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider undeletableStatuses
|
||||
*/
|
||||
#[DataProvider('undeletableStatuses')]
|
||||
public function testOnlyADraftCanBeDeleted(AccommodationBookingStatus $status): void
|
||||
{
|
||||
// Anything past Entwurf has been in contact with the customer and is closed by an
|
||||
@@ -126,7 +125,7 @@ class DeleteControllerTest extends TestCase
|
||||
): TestableBookingDeleteController {
|
||||
return new TestableBookingDeleteController(
|
||||
$entityManager,
|
||||
$this->createMock(LoggerInterface::class),
|
||||
$this->createStub(LoggerInterface::class),
|
||||
$tokenValid,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Controller\Admin\AccommodationBooking\DiscardController;
|
||||
use App\Entity\Groups\AccommodationBooking;
|
||||
use App\Enum\Groups\AccommodationBookingStatus;
|
||||
use App\Service\AccommodationBookingService;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -25,7 +26,7 @@ class DiscardControllerTest extends TestCase
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->expects(self::never())->method('discardBooking');
|
||||
|
||||
$controller = new TestableDiscardController($bookingService, $this->createMock(LoggerInterface::class));
|
||||
$controller = new TestableDiscardController($bookingService, $this->createStub(LoggerInterface::class));
|
||||
|
||||
$response = $controller->index($this->openBooking(), Request::create('/admin/accommodation-booking/1/discard'));
|
||||
|
||||
@@ -33,9 +34,7 @@ class DiscardControllerTest extends TestCase
|
||||
self::assertSame('admin/accommodation_booking/modal_discard.html.twig', $controller->renderedView);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider discardableStatuses
|
||||
*/
|
||||
#[DataProvider('discardableStatuses')]
|
||||
public function testPostDiscardsTheBookingAndRedirectsTheBrowser(AccommodationBookingStatus $status): void
|
||||
{
|
||||
$booking = $this->openBooking();
|
||||
@@ -44,7 +43,7 @@ class DiscardControllerTest extends TestCase
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->expects(self::once())->method('discardBooking')->with($booking);
|
||||
|
||||
$controller = new TestableDiscardController($bookingService, $this->createMock(LoggerInterface::class));
|
||||
$controller = new TestableDiscardController($bookingService, $this->createStub(LoggerInterface::class));
|
||||
|
||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/discard', 'POST'));
|
||||
|
||||
@@ -62,9 +61,7 @@ class DiscardControllerTest extends TestCase
|
||||
yield 'received' => [AccommodationBookingStatus::Received];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider closedStatuses
|
||||
*/
|
||||
#[DataProvider('closedStatuses')]
|
||||
public function testAClosedBookingCannotBeDiscarded(AccommodationBookingStatus $status): void
|
||||
{
|
||||
// A released confirmation is binding, and an Absage is already the end of the line.
|
||||
@@ -74,7 +71,7 @@ class DiscardControllerTest extends TestCase
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->expects(self::never())->method('discardBooking');
|
||||
|
||||
$controller = new TestableDiscardController($bookingService, $this->createMock(LoggerInterface::class));
|
||||
$controller = new TestableDiscardController($bookingService, $this->createStub(LoggerInterface::class));
|
||||
|
||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/discard', 'POST'));
|
||||
|
||||
@@ -95,7 +92,7 @@ class DiscardControllerTest extends TestCase
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->expects(self::never())->method('discardBooking');
|
||||
|
||||
$controller = new TestableDiscardController($bookingService, $this->createMock(LoggerInterface::class), tokenValid: false);
|
||||
$controller = new TestableDiscardController($bookingService, $this->createStub(LoggerInterface::class), tokenValid: false);
|
||||
|
||||
$this->expectException(AccessDeniedException::class);
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ use App\Repository\Groups\BoardServiceRepository;
|
||||
use App\Repository\UserRepository;
|
||||
use App\Service\AccommodationBookingService;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
@@ -26,9 +27,7 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
*/
|
||||
class EditControllerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider everyStatus
|
||||
*/
|
||||
#[DataProvider('everyStatus')]
|
||||
public function testSavingNeverNotifiesTheCustomer(AccommodationBookingStatus $status): void
|
||||
{
|
||||
// Sending used to be a side effect of saving a status change, which is how an inquiry
|
||||
@@ -59,7 +58,7 @@ class EditControllerTest extends TestCase
|
||||
|
||||
private function submitEdit(AccommodationBooking $booking, AccommodationBookingService $bookingService): void
|
||||
{
|
||||
$form = $this->createMock(FormInterface::class);
|
||||
$form = $this->createStub(FormInterface::class);
|
||||
$form->method('handleRequest')->willReturn($form);
|
||||
$form->method('isSubmitted')->willReturn(true);
|
||||
$form->method('isValid')->willReturn(true);
|
||||
@@ -70,10 +69,10 @@ class EditControllerTest extends TestCase
|
||||
|
||||
$controller = new TestableEditController(
|
||||
$entityManager,
|
||||
$this->createMock(LoggerInterface::class),
|
||||
$this->createMock(BoardServiceRepository::class),
|
||||
$this->createMock(AdditionalServiceRepository::class),
|
||||
$this->createMock(UserRepository::class),
|
||||
$this->createStub(LoggerInterface::class),
|
||||
$this->createStub(BoardServiceRepository::class),
|
||||
$this->createStub(AdditionalServiceRepository::class),
|
||||
$this->createStub(UserRepository::class),
|
||||
$bookingService,
|
||||
$form,
|
||||
);
|
||||
@@ -97,7 +96,7 @@ class EditControllerTest extends TestCase
|
||||
public function testAdminGetsTheGroupsStaffAsBetreuerChoices(): void
|
||||
{
|
||||
$staff = [new User('[email protected]')];
|
||||
$userRepo = $this->createMock(UserRepository::class);
|
||||
$userRepo = $this->createStub(UserRepository::class);
|
||||
$userRepo->method('findGroupsStaff')->willReturn($staff);
|
||||
|
||||
$controller = $this->buildController($userRepo, granted: true);
|
||||
@@ -111,7 +110,7 @@ class EditControllerTest extends TestCase
|
||||
$formerManager = new User('[email protected]');
|
||||
$staff = [new User('[email protected]')];
|
||||
|
||||
$userRepo = $this->createMock(UserRepository::class);
|
||||
$userRepo = $this->createStub(UserRepository::class);
|
||||
$userRepo->method('findGroupsStaff')->willReturn($staff);
|
||||
|
||||
$booking = new AccommodationBooking();
|
||||
@@ -127,17 +126,17 @@ class EditControllerTest extends TestCase
|
||||
{
|
||||
// An unsubmitted form: index() falls through to render() and only the options
|
||||
// handed to createForm() are of interest here.
|
||||
$form = $this->createMock(FormInterface::class);
|
||||
$form = $this->createStub(FormInterface::class);
|
||||
$form->method('handleRequest')->willReturn($form);
|
||||
$form->method('isSubmitted')->willReturn(false);
|
||||
|
||||
return new TestableEditController(
|
||||
$this->createMock(EntityManagerInterface::class),
|
||||
$this->createMock(LoggerInterface::class),
|
||||
$this->createMock(BoardServiceRepository::class),
|
||||
$this->createMock(AdditionalServiceRepository::class),
|
||||
$this->createStub(EntityManagerInterface::class),
|
||||
$this->createStub(LoggerInterface::class),
|
||||
$this->createStub(BoardServiceRepository::class),
|
||||
$this->createStub(AdditionalServiceRepository::class),
|
||||
$userRepo,
|
||||
$this->createMock(AccommodationBookingService::class),
|
||||
$this->createStub(AccommodationBookingService::class),
|
||||
$form,
|
||||
$granted,
|
||||
);
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Controller\Admin\AccommodationBooking\GenerateAccessLinkController;
|
||||
use App\Entity\Groups\AccommodationBooking;
|
||||
use App\Enum\Groups\AccommodationBookingStatus;
|
||||
use App\Service\AccommodationBookingService;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -25,7 +26,7 @@ class GenerateAccessLinkControllerTest extends TestCase
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->expects(self::never())->method('generateAccessLink');
|
||||
|
||||
$controller = new TestableGenerateAccessLinkController($bookingService, $this->createMock(LoggerInterface::class));
|
||||
$controller = new TestableGenerateAccessLinkController($bookingService, $this->createStub(LoggerInterface::class));
|
||||
|
||||
$response = $controller->index($this->requestedBooking(), Request::create('/admin/accommodation-booking/1/generate-access-link'));
|
||||
|
||||
@@ -33,9 +34,7 @@ class GenerateAccessLinkControllerTest extends TestCase
|
||||
self::assertSame('admin/accommodation_booking/modal_generate_access_link.html.twig', $controller->renderedView);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider statusesAwaitingAnOffer
|
||||
*/
|
||||
#[DataProvider('statusesAwaitingAnOffer')]
|
||||
public function testPostGeneratesTheLinkAndRedirectsTheBrowser(AccommodationBookingStatus $status): void
|
||||
{
|
||||
$booking = $this->requestedBooking();
|
||||
@@ -44,7 +43,7 @@ class GenerateAccessLinkControllerTest extends TestCase
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->expects(self::once())->method('generateAccessLink')->with($booking);
|
||||
|
||||
$controller = new TestableGenerateAccessLinkController($bookingService, $this->createMock(LoggerInterface::class));
|
||||
$controller = new TestableGenerateAccessLinkController($bookingService, $this->createStub(LoggerInterface::class));
|
||||
|
||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/generate-access-link', 'POST'));
|
||||
|
||||
@@ -60,9 +59,7 @@ class GenerateAccessLinkControllerTest extends TestCase
|
||||
yield 'requested' => [AccommodationBookingStatus::Requested];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider statusesPastTheOffer
|
||||
*/
|
||||
#[DataProvider('statusesPastTheOffer')]
|
||||
public function testABookingThatIsNotAwaitingAnOfferGetsNoLink(AccommodationBookingStatus $status): void
|
||||
{
|
||||
$booking = $this->requestedBooking();
|
||||
@@ -71,7 +68,7 @@ class GenerateAccessLinkControllerTest extends TestCase
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->expects(self::never())->method('generateAccessLink');
|
||||
|
||||
$controller = new TestableGenerateAccessLinkController($bookingService, $this->createMock(LoggerInterface::class));
|
||||
$controller = new TestableGenerateAccessLinkController($bookingService, $this->createStub(LoggerInterface::class));
|
||||
|
||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/generate-access-link', 'POST'));
|
||||
|
||||
@@ -94,7 +91,7 @@ class GenerateAccessLinkControllerTest extends TestCase
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->expects(self::never())->method('generateAccessLink');
|
||||
|
||||
$controller = new TestableGenerateAccessLinkController($bookingService, $this->createMock(LoggerInterface::class), tokenValid: false);
|
||||
$controller = new TestableGenerateAccessLinkController($bookingService, $this->createStub(LoggerInterface::class), tokenValid: false);
|
||||
|
||||
$this->expectException(AccessDeniedException::class);
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Controller\Admin\AccommodationBooking\PdfController;
|
||||
use App\Entity\Groups\AccommodationBooking;
|
||||
use App\Enum\Groups\AccommodationBookingStatus;
|
||||
use App\Service\AccommodationBookingPdfGenerator;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
@@ -32,9 +33,7 @@ class PdfControllerTest extends TestCase
|
||||
self::assertSame(Response::HTTP_OK, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider nonConfirmedStatuses
|
||||
*/
|
||||
#[DataProvider('nonConfirmedStatuses')]
|
||||
public function testABookingThatIsNotConfirmedCannotBeDownloaded(AccommodationBookingStatus $status): void
|
||||
{
|
||||
$generator = $this->createMock(AccommodationBookingPdfGenerator::class);
|
||||
@@ -61,7 +60,7 @@ class PdfControllerTest extends TestCase
|
||||
|
||||
public function testAFailingGeneratorRedirectsWithAFlash(): void
|
||||
{
|
||||
$generator = $this->createMock(AccommodationBookingPdfGenerator::class);
|
||||
$generator = $this->createStub(AccommodationBookingPdfGenerator::class);
|
||||
$generator->method('createDownloadResponse')->willThrowException(new \RuntimeException('keine Preise'));
|
||||
|
||||
$controller = new TestablePdfController($generator);
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Controller\Admin\AccommodationBooking\SendAccessLinkController;
|
||||
use App\Entity\Groups\AccommodationBooking;
|
||||
use App\Enum\Groups\AccommodationBookingStatus;
|
||||
use App\Service\AccommodationBookingService;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -25,7 +26,7 @@ class SendAccessLinkControllerTest extends TestCase
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->expects(self::never())->method('sendAccessLink');
|
||||
|
||||
$controller = new TestableSendAccessLinkController($bookingService, $this->createMock(LoggerInterface::class));
|
||||
$controller = new TestableSendAccessLinkController($bookingService, $this->createStub(LoggerInterface::class));
|
||||
|
||||
$response = $controller->index($this->openBooking(), Request::create('/admin/accommodation-booking/1/send-access-link'));
|
||||
|
||||
@@ -40,7 +41,7 @@ class SendAccessLinkControllerTest extends TestCase
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->expects(self::once())->method('sendAccessLink')->with($booking);
|
||||
|
||||
$controller = new TestableSendAccessLinkController($bookingService, $this->createMock(LoggerInterface::class));
|
||||
$controller = new TestableSendAccessLinkController($bookingService, $this->createStub(LoggerInterface::class));
|
||||
|
||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/send-access-link', 'POST'));
|
||||
|
||||
@@ -55,7 +56,7 @@ class SendAccessLinkControllerTest extends TestCase
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->expects(self::never())->method('sendAccessLink');
|
||||
|
||||
$controller = new TestableSendAccessLinkController($bookingService, $this->createMock(LoggerInterface::class));
|
||||
$controller = new TestableSendAccessLinkController($bookingService, $this->createStub(LoggerInterface::class));
|
||||
|
||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/send-access-link', 'POST'));
|
||||
|
||||
@@ -65,9 +66,8 @@ class SendAccessLinkControllerTest extends TestCase
|
||||
/**
|
||||
* Drafts are held back even when a link is on the record — a booking pushed back into
|
||||
* Entwurf keeps its accessLinkIssuedAt, and it must not be handed out again.
|
||||
*
|
||||
* @dataProvider requestMethods
|
||||
*/
|
||||
#[DataProvider('requestMethods')]
|
||||
public function testADraftLinkIsNeverSentEvenIfOneWasIssuedEarlier(string $method): void
|
||||
{
|
||||
$booking = $this->openBooking();
|
||||
@@ -76,7 +76,7 @@ class SendAccessLinkControllerTest extends TestCase
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->expects(self::never())->method('sendAccessLink');
|
||||
|
||||
$controller = new TestableSendAccessLinkController($bookingService, $this->createMock(LoggerInterface::class));
|
||||
$controller = new TestableSendAccessLinkController($bookingService, $this->createStub(LoggerInterface::class));
|
||||
|
||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/send-access-link', $method));
|
||||
|
||||
@@ -98,7 +98,7 @@ class SendAccessLinkControllerTest extends TestCase
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->expects(self::never())->method('sendAccessLink');
|
||||
|
||||
$controller = new TestableSendAccessLinkController($bookingService, $this->createMock(LoggerInterface::class), tokenValid: false);
|
||||
$controller = new TestableSendAccessLinkController($bookingService, $this->createStub(LoggerInterface::class), tokenValid: false);
|
||||
|
||||
$this->expectException(AccessDeniedException::class);
|
||||
|
||||
@@ -113,7 +113,7 @@ class SendAccessLinkControllerTest extends TestCase
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->expects(self::never())->method('sendAccessLink');
|
||||
|
||||
$controller = new TestableSendAccessLinkController($bookingService, $this->createMock(LoggerInterface::class));
|
||||
$controller = new TestableSendAccessLinkController($bookingService, $this->createStub(LoggerInterface::class));
|
||||
|
||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/send-access-link', 'POST'));
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Controller\Admin\AccommodationBooking\SendOfferController;
|
||||
use App\Entity\Groups\AccommodationBooking;
|
||||
use App\Enum\Groups\AccommodationBookingStatus;
|
||||
use App\Service\AccommodationBookingService;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -25,7 +26,7 @@ class SendOfferControllerTest extends TestCase
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->expects(self::never())->method('sendOffer');
|
||||
|
||||
$controller = new TestableSendOfferController($bookingService, $this->createMock(LoggerInterface::class));
|
||||
$controller = new TestableSendOfferController($bookingService, $this->createStub(LoggerInterface::class));
|
||||
|
||||
$response = $controller->index($this->requestedBooking(), Request::create('/admin/accommodation-booking/1/send-offer'));
|
||||
|
||||
@@ -33,9 +34,7 @@ class SendOfferControllerTest extends TestCase
|
||||
self::assertSame('admin/accommodation_booking/modal_send_offer.html.twig', $controller->renderedView);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider statusesAwaitingAnOffer
|
||||
*/
|
||||
#[DataProvider('statusesAwaitingAnOffer')]
|
||||
public function testPostSendsTheOfferAndRedirectsTheBrowser(AccommodationBookingStatus $status): void
|
||||
{
|
||||
$booking = $this->requestedBooking();
|
||||
@@ -44,7 +43,7 @@ class SendOfferControllerTest extends TestCase
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->expects(self::once())->method('sendOffer')->with($booking);
|
||||
|
||||
$controller = new TestableSendOfferController($bookingService, $this->createMock(LoggerInterface::class));
|
||||
$controller = new TestableSendOfferController($bookingService, $this->createStub(LoggerInterface::class));
|
||||
|
||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/send-offer', 'POST'));
|
||||
|
||||
@@ -61,9 +60,7 @@ class SendOfferControllerTest extends TestCase
|
||||
yield 'requested' => [AccommodationBookingStatus::Requested];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider statusesPastTheOffer
|
||||
*/
|
||||
#[DataProvider('statusesPastTheOffer')]
|
||||
public function testABookingThatIsNotAwaitingAnOfferGetsNone(AccommodationBookingStatus $status): void
|
||||
{
|
||||
$booking = $this->requestedBooking();
|
||||
@@ -72,7 +69,7 @@ class SendOfferControllerTest extends TestCase
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->expects(self::never())->method('sendOffer');
|
||||
|
||||
$controller = new TestableSendOfferController($bookingService, $this->createMock(LoggerInterface::class));
|
||||
$controller = new TestableSendOfferController($bookingService, $this->createStub(LoggerInterface::class));
|
||||
|
||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/send-offer', 'POST'));
|
||||
|
||||
@@ -95,7 +92,7 @@ class SendOfferControllerTest extends TestCase
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->expects(self::never())->method('sendOffer');
|
||||
|
||||
$controller = new TestableSendOfferController($bookingService, $this->createMock(LoggerInterface::class), tokenValid: false);
|
||||
$controller = new TestableSendOfferController($bookingService, $this->createStub(LoggerInterface::class), tokenValid: false);
|
||||
|
||||
$this->expectException(AccessDeniedException::class);
|
||||
|
||||
@@ -113,7 +110,7 @@ class SendOfferControllerTest extends TestCase
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->expects(self::never())->method('sendOffer');
|
||||
|
||||
$controller = new TestableSendOfferController($bookingService, $this->createMock(LoggerInterface::class));
|
||||
$controller = new TestableSendOfferController($bookingService, $this->createStub(LoggerInterface::class));
|
||||
|
||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/send-offer', 'POST'));
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class ApproveRoleControllerTest extends TestCase
|
||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
$entityManager->expects(self::never())->method('flush');
|
||||
|
||||
$controller = new TestableApproveRoleController($entityManager, $this->createMock(LoggerInterface::class));
|
||||
$controller = new TestableApproveRoleController($entityManager, $this->createStub(LoggerInterface::class));
|
||||
|
||||
$response = $controller->index($user, Role::GROUPS_ADMIN, Request::create('/admin/user/1/approve/ROLE_GROUPS_ADMIN'));
|
||||
|
||||
@@ -47,7 +47,7 @@ class ApproveRoleControllerTest extends TestCase
|
||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
$entityManager->expects(self::once())->method('flush');
|
||||
|
||||
$controller = new TestableApproveRoleController($entityManager, $this->createMock(LoggerInterface::class));
|
||||
$controller = new TestableApproveRoleController($entityManager, $this->createStub(LoggerInterface::class));
|
||||
|
||||
$response = $controller->index($user, Role::GROUPS_ADMIN, Request::create('/admin/user/1/approve/ROLE_GROUPS_ADMIN', 'POST'));
|
||||
|
||||
@@ -61,7 +61,7 @@ class ApproveRoleControllerTest extends TestCase
|
||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
$entityManager->expects(self::never())->method('flush');
|
||||
|
||||
$controller = new TestableApproveRoleController($entityManager, $this->createMock(LoggerInterface::class));
|
||||
$controller = new TestableApproveRoleController($entityManager, $this->createStub(LoggerInterface::class));
|
||||
|
||||
$this->expectException(NotFoundHttpException::class);
|
||||
|
||||
@@ -76,7 +76,7 @@ class ApproveRoleControllerTest extends TestCase
|
||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
$entityManager->expects(self::never())->method('flush');
|
||||
|
||||
$controller = new TestableApproveRoleController($entityManager, $this->createMock(LoggerInterface::class), currentUser: $user);
|
||||
$controller = new TestableApproveRoleController($entityManager, $this->createStub(LoggerInterface::class), currentUser: $user);
|
||||
|
||||
$this->expectException(AccessDeniedException::class);
|
||||
|
||||
@@ -90,7 +90,7 @@ class ApproveRoleControllerTest extends TestCase
|
||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
$entityManager->expects(self::once())->method('flush');
|
||||
|
||||
$controller = new TestableApproveRoleController($entityManager, $this->createMock(LoggerInterface::class), currentUser: $user);
|
||||
$controller = new TestableApproveRoleController($entityManager, $this->createStub(LoggerInterface::class), currentUser: $user);
|
||||
|
||||
// Only ROLE_ADMIN needs a second pair of eyes — an approver already holds it, so the
|
||||
// rest grant less than they could grant themselves anyway.
|
||||
@@ -104,7 +104,7 @@ class ApproveRoleControllerTest extends TestCase
|
||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
$entityManager->expects(self::never())->method('flush');
|
||||
|
||||
$controller = new TestableApproveRoleController($entityManager, $this->createMock(LoggerInterface::class), tokenValid: false);
|
||||
$controller = new TestableApproveRoleController($entityManager, $this->createStub(LoggerInterface::class), tokenValid: false);
|
||||
|
||||
$this->expectException(AccessDeniedException::class);
|
||||
|
||||
@@ -119,8 +119,8 @@ class ApproveRoleControllerTest extends TestCase
|
||||
$tokenStorage->setToken(new PostAuthenticationToken($user, 'main', $user->getRoles()));
|
||||
|
||||
$controller = new TestableApproveRoleController(
|
||||
$this->createMock(EntityManagerInterface::class),
|
||||
$this->createMock(LoggerInterface::class),
|
||||
$this->createStub(EntityManagerInterface::class),
|
||||
$this->createStub(LoggerInterface::class),
|
||||
currentUser: $user,
|
||||
tokenStorage: $tokenStorage,
|
||||
);
|
||||
@@ -142,8 +142,8 @@ class ApproveRoleControllerTest extends TestCase
|
||||
$tokenStorage->setToken($originalToken = new PostAuthenticationToken($admin, 'main', $admin->getRoles()));
|
||||
|
||||
$controller = new TestableApproveRoleController(
|
||||
$this->createMock(EntityManagerInterface::class),
|
||||
$this->createMock(LoggerInterface::class),
|
||||
$this->createStub(EntityManagerInterface::class),
|
||||
$this->createStub(LoggerInterface::class),
|
||||
currentUser: $admin,
|
||||
tokenStorage: $tokenStorage,
|
||||
);
|
||||
|
||||
@@ -157,10 +157,10 @@ class AccommodationBookingControllerTest extends TestCase
|
||||
->with(['uuid' => $booking->getUuid()])
|
||||
->willReturn($booking);
|
||||
|
||||
$breakdownCalculator = $this->createMock(AccommodationBookingBreakdownCalculator::class);
|
||||
$breakdownCalculator = $this->createStub(AccommodationBookingBreakdownCalculator::class);
|
||||
$breakdownCalculator->method('compute')->willReturn(null);
|
||||
|
||||
$controller = new AccommodationBookingController($bookingRepository, $breakdownCalculator, $this->serializer(), $this->createMock(AccommodationBookingService::class));
|
||||
$controller = new AccommodationBookingController($bookingRepository, $breakdownCalculator, $this->serializer(), $this->createStub(AccommodationBookingService::class));
|
||||
|
||||
$response = $controller->single($booking->getUuid());
|
||||
$payload = json_decode((string) $response->getContent(), true, 512, JSON_THROW_ON_ERROR);
|
||||
@@ -183,7 +183,7 @@ class AccommodationBookingControllerTest extends TestCase
|
||||
$breakdownCalculator = $this->createMock(AccommodationBookingBreakdownCalculator::class);
|
||||
$breakdownCalculator->expects(self::never())->method('compute');
|
||||
|
||||
$controller = new AccommodationBookingController($bookingRepository, $breakdownCalculator, $this->serializer(), $this->createMock(AccommodationBookingService::class));
|
||||
$controller = new AccommodationBookingController($bookingRepository, $breakdownCalculator, $this->serializer(), $this->createStub(AccommodationBookingService::class));
|
||||
|
||||
$response = $controller->single('unknown-uuid');
|
||||
$payload = json_decode((string) $response->getContent(), true, 512, JSON_THROW_ON_ERROR);
|
||||
@@ -210,7 +210,7 @@ class AccommodationBookingControllerTest extends TestCase
|
||||
->with(['uuid' => $booking->getUuid()])
|
||||
->willReturn($booking);
|
||||
|
||||
$breakdownCalculator = $this->createMock(AccommodationBookingBreakdownCalculator::class);
|
||||
$breakdownCalculator = $this->createStub(AccommodationBookingBreakdownCalculator::class);
|
||||
$breakdownCalculator->method('compute')->willReturn(null);
|
||||
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
@@ -256,7 +256,7 @@ class AccommodationBookingControllerTest extends TestCase
|
||||
->with(['uuid' => $booking->getUuid()])
|
||||
->willReturn($booking);
|
||||
|
||||
$breakdownCalculator = $this->createMock(AccommodationBookingBreakdownCalculator::class);
|
||||
$breakdownCalculator = $this->createStub(AccommodationBookingBreakdownCalculator::class);
|
||||
$breakdownCalculator->method('compute')->willReturn(null);
|
||||
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
|
||||
@@ -190,7 +190,7 @@ class ContingentControllerTest extends TestCase
|
||||
*/
|
||||
private function callFullSpanCalendar(?array $bounds, array $prices, array $statuses = []): array
|
||||
{
|
||||
$priceRepository = $this->createMock(AccommodationPriceRepository::class);
|
||||
$priceRepository = $this->createStub(AccommodationPriceRepository::class);
|
||||
$priceRepository->method('findPricedDateBoundsByHotelCode')->willReturn($bounds);
|
||||
$priceRepository->method('findByHotelCodeAndDateRange')->willReturn($prices);
|
||||
|
||||
@@ -214,13 +214,13 @@ class ContingentControllerTest extends TestCase
|
||||
?array $prices = null,
|
||||
?AccommodationPriceRepository $priceRepository = null,
|
||||
): Response {
|
||||
$accommodationRepository = $this->createMock(AccommodationRepository::class);
|
||||
$accommodationRepository = $this->createStub(AccommodationRepository::class);
|
||||
$accommodationRepository->method('findOneBy')->willReturn((new Accommodation())->setCalendarCode('HOTEL1')->setCurrency('EUR'));
|
||||
|
||||
$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);
|
||||
|
||||
if (null !== $prices) {
|
||||
$priceRepository->method('findByHotelCodeAndDateRange')->willReturn($prices);
|
||||
@@ -231,8 +231,8 @@ class ContingentControllerTest extends TestCase
|
||||
$priceRepository,
|
||||
$snapshotReader,
|
||||
new PriceTimelineBuilder(),
|
||||
new AccommodationPriceCoverage($this->createMock(AccommodationPriceRepository::class)),
|
||||
$this->createMock(LoggerInterface::class),
|
||||
new AccommodationPriceCoverage($this->createStub(AccommodationPriceRepository::class)),
|
||||
$this->createStub(LoggerInterface::class),
|
||||
);
|
||||
|
||||
// No 'serializer' service registered, so AbstractController::json() falls back to
|
||||
@@ -245,12 +245,12 @@ class ContingentControllerTest extends TestCase
|
||||
private function createController(): ContingentController
|
||||
{
|
||||
return new ContingentController(
|
||||
$this->createMock(AccommodationRepository::class),
|
||||
$this->createMock(AccommodationPriceRepository::class),
|
||||
$this->createMock(ContingentSnapshotReader::class),
|
||||
$this->createStub(AccommodationRepository::class),
|
||||
$this->createStub(AccommodationPriceRepository::class),
|
||||
$this->createStub(ContingentSnapshotReader::class),
|
||||
new PriceTimelineBuilder(),
|
||||
new AccommodationPriceCoverage($this->createMock(AccommodationPriceRepository::class)),
|
||||
$this->createMock(LoggerInterface::class),
|
||||
new AccommodationPriceCoverage($this->createStub(AccommodationPriceRepository::class)),
|
||||
$this->createStub(LoggerInterface::class),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ use App\Service\BookingEditDraftManager;
|
||||
use App\Service\BookingEditPreFlightChecker;
|
||||
use App\Service\BookingEditSubmitter;
|
||||
use App\Service\BookingSessionManager;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\NullLogger;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
@@ -62,7 +63,7 @@ class IndexControllerTest extends TestCase
|
||||
];
|
||||
$bookingData = $this->createBooking();
|
||||
|
||||
$form = $this->createMock(FormInterface::class);
|
||||
$form = $this->createStub(FormInterface::class);
|
||||
$form->method('isSubmitted')->willReturn(false);
|
||||
|
||||
$fingerprintService = $this->createMock(BookingChangeTracker::class);
|
||||
@@ -110,13 +111,13 @@ class IndexControllerTest extends TestCase
|
||||
|
||||
$controller = new TestableIndexController(
|
||||
$dataLoader,
|
||||
$this->createMock(BookingEditDraftManager::class),
|
||||
$this->createStub(BookingEditDraftManager::class),
|
||||
$bookingSessionService,
|
||||
$fingerprintService,
|
||||
$bookingConfigurator,
|
||||
$contextFactory,
|
||||
$preflightChecker,
|
||||
$this->createMock(BookingEditSubmitter::class),
|
||||
$this->createStub(BookingEditSubmitter::class),
|
||||
$user,
|
||||
$form,
|
||||
);
|
||||
@@ -147,7 +148,7 @@ class IndexControllerTest extends TestCase
|
||||
];
|
||||
$bookingData = $this->createBooking();
|
||||
|
||||
$form = $this->createMock(FormInterface::class);
|
||||
$form = $this->createStub(FormInterface::class);
|
||||
$form->method('isSubmitted')->willReturn(false);
|
||||
|
||||
$fingerprintService = $this->createMock(BookingChangeTracker::class);
|
||||
@@ -187,13 +188,13 @@ class IndexControllerTest extends TestCase
|
||||
|
||||
$controller = new TestableIndexController(
|
||||
$dataLoader,
|
||||
$this->createMock(BookingEditDraftManager::class),
|
||||
$this->createMock(BookingSessionManager::class),
|
||||
$this->createStub(BookingEditDraftManager::class),
|
||||
$this->createStub(BookingSessionManager::class),
|
||||
$fingerprintService,
|
||||
$this->createMock(BookingConfigurator::class),
|
||||
$this->createStub(BookingConfigurator::class),
|
||||
$contextFactory,
|
||||
$preflightChecker,
|
||||
$this->createMock(BookingEditSubmitter::class),
|
||||
$this->createStub(BookingEditSubmitter::class),
|
||||
$user,
|
||||
$form,
|
||||
);
|
||||
@@ -275,10 +276,10 @@ class IndexControllerTest extends TestCase
|
||||
|
||||
$controller = new TestableIndexController(
|
||||
$dataLoader,
|
||||
$this->createMock(BookingEditDraftManager::class),
|
||||
$this->createMock(BookingSessionManager::class),
|
||||
$this->createStub(BookingEditDraftManager::class),
|
||||
$this->createStub(BookingSessionManager::class),
|
||||
$fingerprintService,
|
||||
$this->createMock(BookingConfigurator::class),
|
||||
$this->createStub(BookingConfigurator::class),
|
||||
$contextFactory,
|
||||
$preflightChecker,
|
||||
$submitter,
|
||||
@@ -362,10 +363,10 @@ class IndexControllerTest extends TestCase
|
||||
|
||||
$controller = new TestableIndexController(
|
||||
$dataLoader,
|
||||
$this->createMock(BookingEditDraftManager::class),
|
||||
$this->createMock(BookingSessionManager::class),
|
||||
$this->createStub(BookingEditDraftManager::class),
|
||||
$this->createStub(BookingSessionManager::class),
|
||||
$fingerprintService,
|
||||
$this->createMock(BookingConfigurator::class),
|
||||
$this->createStub(BookingConfigurator::class),
|
||||
$contextFactory,
|
||||
$preflightChecker,
|
||||
$submitter,
|
||||
@@ -390,7 +391,7 @@ class IndexControllerTest extends TestCase
|
||||
$bookingDto->participants = [$this->createParticipant()];
|
||||
$bookingData = $this->createBooking();
|
||||
|
||||
$form = $this->createMock(FormInterface::class);
|
||||
$form = $this->createStub(FormInterface::class);
|
||||
$form->method('isSubmitted')->willReturn(false);
|
||||
|
||||
$fingerprintService = $this->createMock(BookingChangeTracker::class);
|
||||
@@ -433,13 +434,13 @@ class IndexControllerTest extends TestCase
|
||||
|
||||
$controller = new TestableIndexController(
|
||||
$dataLoader,
|
||||
$this->createMock(BookingEditDraftManager::class),
|
||||
$this->createMock(BookingSessionManager::class),
|
||||
$this->createStub(BookingEditDraftManager::class),
|
||||
$this->createStub(BookingSessionManager::class),
|
||||
$fingerprintService,
|
||||
$bookingConfigurator,
|
||||
$contextFactory,
|
||||
$this->createPreflightChecker($bookingDto),
|
||||
$this->createMock(BookingEditSubmitter::class),
|
||||
$this->createStub(BookingEditSubmitter::class),
|
||||
$user,
|
||||
$form,
|
||||
);
|
||||
@@ -460,7 +461,7 @@ class IndexControllerTest extends TestCase
|
||||
$bookingDto->participants = [$this->createParticipant()];
|
||||
$bookingData = $this->createBooking();
|
||||
|
||||
$form = $this->createMock(FormInterface::class);
|
||||
$form = $this->createStub(FormInterface::class);
|
||||
$form->method('isSubmitted')->willReturn(false);
|
||||
|
||||
$fingerprintService = $this->createMock(BookingChangeTracker::class);
|
||||
@@ -501,13 +502,13 @@ class IndexControllerTest extends TestCase
|
||||
|
||||
$controller = new TestableIndexController(
|
||||
$dataLoader,
|
||||
$this->createMock(BookingEditDraftManager::class),
|
||||
$this->createMock(BookingSessionManager::class),
|
||||
$this->createStub(BookingEditDraftManager::class),
|
||||
$this->createStub(BookingSessionManager::class),
|
||||
$fingerprintService,
|
||||
$bookingConfigurator,
|
||||
$contextFactory,
|
||||
$this->createPreflightChecker($bookingDto),
|
||||
$this->createMock(BookingEditSubmitter::class),
|
||||
$this->createStub(BookingEditSubmitter::class),
|
||||
$user,
|
||||
$form,
|
||||
);
|
||||
@@ -543,13 +544,13 @@ class IndexControllerTest extends TestCase
|
||||
$dataLoader,
|
||||
$draftService,
|
||||
$bookingSessionService,
|
||||
$this->createMock(BookingChangeTracker::class),
|
||||
$this->createMock(BookingConfigurator::class),
|
||||
$this->createMock(BookingEditContextFactory::class),
|
||||
$this->createMock(BookingEditPreFlightChecker::class),
|
||||
$this->createMock(BookingEditSubmitter::class),
|
||||
$this->createStub(BookingChangeTracker::class),
|
||||
$this->createStub(BookingConfigurator::class),
|
||||
$this->createStub(BookingEditContextFactory::class),
|
||||
$this->createStub(BookingEditPreFlightChecker::class),
|
||||
$this->createStub(BookingEditSubmitter::class),
|
||||
$user,
|
||||
$this->createMock(FormInterface::class),
|
||||
$this->createStub(FormInterface::class),
|
||||
);
|
||||
|
||||
$response = $controller->reloadFromApi(42, $request);
|
||||
@@ -560,11 +561,11 @@ class IndexControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider submissionResultProvider
|
||||
*
|
||||
* @param array<int, array{0: string, 1: string}> $expectedFlashes
|
||||
*
|
||||
* @phpstan-param array<int, array{0: string, 1: string}> $expectedFlashes
|
||||
*/
|
||||
#[DataProvider('submissionResultProvider')]
|
||||
public function testIndexAppliesErrorSubmissionResultFlashesAndRedirectsBackToEditPage(
|
||||
BookingEditSubmissionResult $submissionResult,
|
||||
array $expectedFlashes,
|
||||
@@ -673,7 +674,7 @@ class IndexControllerTest extends TestCase
|
||||
bookingDto: $bookingDto,
|
||||
bookingData: $bookingData,
|
||||
mutableData: null,
|
||||
summaryData: $this->createMock(BookingSummaryDto::class),
|
||||
summaryData: $this->createStub(BookingSummaryDto::class),
|
||||
cardsData: [
|
||||
0 => new ParticipantCardDataDto(
|
||||
'One',
|
||||
@@ -755,11 +756,11 @@ class IndexControllerTest extends TestCase
|
||||
|
||||
$controller = new TestableIndexController(
|
||||
$dataLoader,
|
||||
$this->createMock(BookingEditDraftManager::class),
|
||||
$this->createMock(BookingSessionManager::class),
|
||||
$this->createStub(BookingEditDraftManager::class),
|
||||
$this->createStub(BookingSessionManager::class),
|
||||
$fingerprintService,
|
||||
$this->createMock(BookingConfigurator::class),
|
||||
$this->createMock(BookingEditContextFactory::class),
|
||||
$this->createStub(BookingConfigurator::class),
|
||||
$this->createStub(BookingEditContextFactory::class),
|
||||
$preflightChecker,
|
||||
$submitter,
|
||||
$user,
|
||||
|
||||
@@ -86,9 +86,9 @@ class ParticipantControllerTest extends TestCase
|
||||
->with($user, 42, $bookingDto);
|
||||
|
||||
$prepopulationService = new ParticipantDataPrefiller(
|
||||
$this->createMock(ApiClient::class),
|
||||
$this->createMock(Crypt::class),
|
||||
$this->createMock(LoggerInterface::class),
|
||||
$this->createStub(ApiClient::class),
|
||||
$this->createStub(Crypt::class),
|
||||
$this->createStub(LoggerInterface::class),
|
||||
);
|
||||
|
||||
$participantFormSupportService = $this->createMock(ParticipantFormSupport::class);
|
||||
@@ -115,7 +115,7 @@ class ParticipantControllerTest extends TestCase
|
||||
],
|
||||
]);
|
||||
|
||||
$summaryData = $this->createMock(BookingSummaryDto::class);
|
||||
$summaryData = $this->createStub(BookingSummaryDto::class);
|
||||
$context = new BookingEditContext($bookingDto, $bookingData, null, $summaryData);
|
||||
|
||||
$contextFactory = $this->createMock(BookingEditContextFactory::class);
|
||||
@@ -131,7 +131,7 @@ class ParticipantControllerTest extends TestCase
|
||||
$dataLoader,
|
||||
$draftService,
|
||||
$contextFactory,
|
||||
$this->createMock(BookingConfigurator::class),
|
||||
$this->createStub(BookingConfigurator::class),
|
||||
$bookingSessionService,
|
||||
$prepopulationService,
|
||||
$participantFormSupportService,
|
||||
@@ -217,7 +217,7 @@ class ParticipantControllerTest extends TestCase
|
||||
->with($bookingDto)
|
||||
->willReturn([]);
|
||||
|
||||
$summaryData = $this->createMock(BookingSummaryDto::class);
|
||||
$summaryData = $this->createStub(BookingSummaryDto::class);
|
||||
$context = new BookingEditContext($bookingDto, $bookingData, null, $summaryData);
|
||||
|
||||
$contextFactory = $this->createMock(BookingEditContextFactory::class);
|
||||
@@ -230,14 +230,14 @@ class ParticipantControllerTest extends TestCase
|
||||
->willReturn($context);
|
||||
|
||||
$prepopulationService = new ParticipantDataPrefiller(
|
||||
$this->createMock(ApiClient::class),
|
||||
$this->createMock(Crypt::class),
|
||||
$this->createMock(LoggerInterface::class),
|
||||
$this->createStub(ApiClient::class),
|
||||
$this->createStub(Crypt::class),
|
||||
$this->createStub(LoggerInterface::class),
|
||||
);
|
||||
|
||||
$controller = new TestableParticipantController(
|
||||
$dataLoader,
|
||||
$this->createMock(BookingEditDraftManager::class),
|
||||
$this->createStub(BookingEditDraftManager::class),
|
||||
$contextFactory,
|
||||
$bookingConfigurator,
|
||||
$bookingSessionService,
|
||||
@@ -286,17 +286,17 @@ class ParticipantControllerTest extends TestCase
|
||||
$bookingDto->originalFingerprint = $changeTracker->generateFingerprint($bookingDto);
|
||||
$this->assertFalse($changeTracker->isDirty($bookingDto), 'Baseline must start clean');
|
||||
|
||||
$form = $this->createMock(FormInterface::class);
|
||||
$form = $this->createStub(FormInterface::class);
|
||||
$form->method('handleRequest')->willReturnSelf();
|
||||
$form->method('createView')->willReturn(new FormView());
|
||||
|
||||
$dataLoader = $this->createMock(BookingEditDataLoader::class);
|
||||
$dataLoader = $this->createStub(BookingEditDataLoader::class);
|
||||
$dataLoader->method('fetchBookingData')->willReturn($bookingData);
|
||||
|
||||
$bookingSessionService = $this->createMock(BookingSessionManager::class);
|
||||
$bookingSessionService = $this->createStub(BookingSessionManager::class);
|
||||
$bookingSessionService->method('getBookingDto')->willReturn($bookingDto);
|
||||
|
||||
$participantFormSupportService = $this->createMock(ParticipantFormSupport::class);
|
||||
$participantFormSupportService = $this->createStub(ParticipantFormSupport::class);
|
||||
$participantFormSupportService->method('ensureParticipantExists')->willReturn($participant);
|
||||
$participantFormSupportService->method('createParticipantEditDto')
|
||||
->willReturn(new ParticipantEditDto($participant, $bookingDto));
|
||||
@@ -306,21 +306,21 @@ class ParticipantControllerTest extends TestCase
|
||||
]);
|
||||
$participantFormSupportService->method('collectAndClearNotifications')->willReturn([]);
|
||||
|
||||
$summaryData = $this->createMock(BookingSummaryDto::class);
|
||||
$contextFactory = $this->createMock(BookingEditContextFactory::class);
|
||||
$summaryData = $this->createStub(BookingSummaryDto::class);
|
||||
$contextFactory = $this->createStub(BookingEditContextFactory::class);
|
||||
$contextFactory->method('createParticipantContext')
|
||||
->willReturn(new BookingEditContext($bookingDto, $bookingData, null, $summaryData));
|
||||
|
||||
$controller = new TestableParticipantController(
|
||||
$dataLoader,
|
||||
$this->createMock(BookingEditDraftManager::class),
|
||||
$this->createStub(BookingEditDraftManager::class),
|
||||
$contextFactory,
|
||||
$this->createMock(BookingConfigurator::class),
|
||||
$this->createStub(BookingConfigurator::class),
|
||||
$bookingSessionService,
|
||||
new ParticipantDataPrefiller(
|
||||
$this->createMock(ApiClient::class),
|
||||
$this->createMock(Crypt::class),
|
||||
$this->createMock(LoggerInterface::class),
|
||||
$this->createStub(ApiClient::class),
|
||||
$this->createStub(Crypt::class),
|
||||
$this->createStub(LoggerInterface::class),
|
||||
),
|
||||
$participantFormSupportService,
|
||||
$user,
|
||||
|
||||
@@ -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'));
|
||||
|
||||
Reference in New Issue
Block a user