client = static::createClient(server: ['HTTPS' => true]); $this->entityManager = self::getContainer()->get(EntityManagerInterface::class); $this->entityManager->createQuery(sprintf('DELETE FROM %s', ApplicationFormSubmission::class))->execute(); $this->entityManager->createQuery(sprintf('DELETE FROM %s', User::class))->execute(); $this->client->loginUser($this->reviewer()); } public function testTheDisabledFeatureHidesTheRouteEntirely(): void { $this->client->request('GET', $this->url()); $this->assertSame(Response::HTTP_NOT_FOUND, $this->client->getResponse()->getStatusCode()); } /** * The POST is the one that writes, so it is pinned separately rather than trusted to share the * guard with the GET. */ public function testTheDisabledFeatureRefusesThePostAsWell(): void { $this->client->request('POST', $this->url()); $this->assertSame(Response::HTTP_NOT_FOUND, $this->client->getResponse()->getStatusCode()); $this->assertNull($this->submission()->getTeamerCreatedAt()); } public function testTheDetailPageOffersNoProvisioningWhileTheFeatureIsOff(): void { $crawler = $this->client->request( 'GET', sprintf('/admin/application-form-submission/detail/%s', $this->submission()->getUuid()) ); $this->assertSame(Response::HTTP_OK, $this->client->getResponse()->getStatusCode()); $this->assertCount(0, $crawler->filter('button[hx-get*="create-teamer"]')); } private function url(): string { return sprintf('/admin/application-form-submission/create-teamer/%s', $this->submission()->getUuid()); } private function submission(): ApplicationFormSubmission { $repository = $this->entityManager->getRepository(ApplicationFormSubmission::class); $submission = $repository->findOneBy([], ['id' => 'DESC']); if (null !== $submission) { return $submission; } $submission = (new ApplicationFormSubmission( 'applicationform', 'Bewerbungsformular', new \DateTimeImmutable('2026-09-22T12:30:00+02:00'), 'F' )) ->setFirstName('Anna') ->setLastName('Muster') ->setEmail('anna@example.com') ->setBirthDate('1990-01-01') ; $this->entityManager->persist($submission); $this->entityManager->flush(); return $submission; } private function reviewer(): User { $user = (new User()) ->setFirstName('Rita') ->setLastName('Reviewer') ->setEmail('rita.reviewer@example.com') ->setRoles(['ROLE_TEAM_ADMIN']) ->setBusProAddressId(1) ->setBusProPersonId(1) ; $this->entityManager->persist($user); $this->entityManager->flush(); return $user; } }