mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-07-10 01:20: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
46 lines
1.6 KiB
PHP
46 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tvdt\Tests\Controller\Backoffice;
|
|
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
use Tvdt\Controller\Backoffice\BackofficeController;
|
|
use Tvdt\Tests\Controller\AbstractControllerWebTestCase;
|
|
|
|
#[CoversClass(BackofficeController::class)]
|
|
final class BackofficeControllerTest extends AbstractControllerWebTestCase
|
|
{
|
|
public function testExportQuizFilenameIsSanitized(): void
|
|
{
|
|
$user = $this->getUserByEmail('user2@example.org');
|
|
$user->isVerified = true;
|
|
|
|
$this->entityManager->flush();
|
|
$this->client->loginUser($user);
|
|
|
|
$quiz = $this->getQuizByName('Quiz 1');
|
|
|
|
$this->client->request(Request::METHOD_GET, \sprintf('/backoffice/quiz/%s/export', $quiz->id));
|
|
|
|
self::assertResponseIsSuccessful();
|
|
$disposition = (string) $this->client->getResponse()->headers->get('Content-Disposition');
|
|
$this->assertStringContainsString('filename=Quiz-1.xlsx', $disposition);
|
|
$this->assertStringNotContainsString('Quiz 1.xlsx', $disposition);
|
|
}
|
|
|
|
public function testExportQuizRequiresVerifiedEmail(): void
|
|
{
|
|
$user = $this->getUserByEmail('user2@example.org');
|
|
$this->assertFalse($user->isVerified);
|
|
$this->client->loginUser($user);
|
|
|
|
$quiz = $this->getQuizByName('Quiz 1');
|
|
|
|
$this->client->request(Request::METHOD_GET, \sprintf('/backoffice/quiz/%s/export', $quiz->id));
|
|
|
|
self::assertResponseRedirects(\sprintf('/backoffice/season/%s', $quiz->season->seasonCode));
|
|
}
|
|
}
|