feat: upgrade phpunit to 12.5
This commit is contained in:
@@ -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,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user