mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-07-10 09:30:14 +02:00
0aa15415de
- Add #[CoversClass] to Base64Test and FilenameSanitizerTest - Merge near-duplicate test methods into #[DataProvider] cases across ResetPasswordControllerTest, SettingsControllerTest, ClaimSeasonCommandTest, FilenameSanitizerTest, Base64Test, and SeasonRepositoryTest - Add integration tests for previously untested controllers: public QuizController (quiz-taking flow), LoginController, RegistrationController, EliminationController, and PrepareEliminationController - Add unit tests for Elimination and BankQuestion entity logic - Extract shared WebTestCase setup/helpers (client, entityManager, login, entity lookups, CSRF token scraping) into AbstractControllerWebTestCase, removing duplicated boilerplate from all 14 WebTestCase files
40 lines
1.3 KiB
PHP
40 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tvdt\Tests\Controller;
|
|
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
use Safe\DateTimeImmutable;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
use Tvdt\Controller\WellKnownController;
|
|
|
|
#[CoversClass(WellKnownController::class)]
|
|
final class WellKnownControllerTest extends AbstractControllerWebTestCase
|
|
{
|
|
public function testChangePasswordRedirectsToSettings(): void
|
|
{
|
|
$this->client->request(Request::METHOD_GET, '/.well-known/change-password');
|
|
|
|
self::assertResponseRedirects('/backoffice/settings');
|
|
}
|
|
|
|
/** @throws \Exception */
|
|
public function testSecurityTxt(): void
|
|
{
|
|
$this->client->request(Request::METHOD_GET, '/.well-known/security.txt');
|
|
|
|
self::assertResponseIsSuccessful();
|
|
self::assertResponseHeaderSame('Content-Type', 'text/plain; charset=UTF-8');
|
|
|
|
$content = (string) $this->client->getResponse()->getContent();
|
|
$this->assertStringContainsString('Contact:', $content);
|
|
$this->assertMatchesRegularExpression('/^Expires: (.+)$/m', $content);
|
|
|
|
\Safe\preg_match('/^Expires: (.+)$/m', $content, $matches);
|
|
$this->assertArrayHasKey(1, $matches);
|
|
$expires = new DateTimeImmutable($matches[1]);
|
|
$this->assertGreaterThan(new DateTimeImmutable('now'), $expires);
|
|
}
|
|
}
|