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 testTheActionsCarryTheReturnUrlTheyWereGivenOn(): void { $submission = $this->submission(); $crawler = $this->client->request( 'GET', sprintf('/admin/application-form-submission/detail/%s', $submission->getUuid()), ['r' => rawurlencode(self::LIST_URL)] ); $this->assertSame(Response::HTTP_OK, $this->client->getResponse()->getStatusCode()); // "zurück" goes where the reviewer came from. $this->assertSame(self::LIST_URL, $crawler->filter('a.btn')->first()->attr('href')); foreach (['send-receipt', 'send-follow-up'] as $action) { $button = $crawler->filter(sprintf('button[hx-get*="%s"]', $action)); $this->assertCount(1, $button, sprintf('The %s button is missing', $action)); $url = $button->attr('hx-get'); $this->assertStringContainsString('r='.rawurlencode(self::LIST_URL), $url); // The bug: the detail url itself as the return url, which "zurück" then loops on. $this->assertStringNotContainsString('detail', urldecode(substr($url, (int) strpos($url, 'r=')))); } } public function testWithoutAReturnUrlTheActionsCarryNone(): void { $submission = $this->submission(); $crawler = $this->client->request( 'GET', sprintf('/admin/application-form-submission/detail/%s', $submission->getUuid()) ); $this->assertSame(Response::HTTP_OK, $this->client->getResponse()->getStatusCode()); // Dropped rather than emitted empty, so the controllers fall back to the list route. $this->assertStringNotContainsString('r=', $crawler->filter('button[hx-get*="send-receipt"]')->attr('hx-get')); $this->assertSame(self::LIST_URL, $crawler->filter('a.btn')->first()->attr('href')); } private function submission(): ApplicationFormSubmission { $submission = (new ApplicationFormSubmission( 'applicationform', 'Bewerbungsformular', new \DateTimeImmutable('2026-09-22T12:30:00+02:00') ))->setEmail('anna@example.com'); $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; } }