mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-07-11 20:38:21 +02:00
test: expand coverage, dedupe data-driven tests, extract shared WebTestCase base
- 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
This commit is contained in:
@@ -5,25 +5,28 @@ declare(strict_types=1);
|
||||
namespace Tvdt\Tests\Repository;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Tvdt\Entity\Season;
|
||||
use Tvdt\Repository\SeasonRepository;
|
||||
|
||||
#[CoversClass(SeasonRepository::class)]
|
||||
final class SeasonRepositoryTest extends DatabaseTestCase
|
||||
{
|
||||
public function testGetSeasonsForUser(): void
|
||||
/** @return iterable<string, array{string, string}> */
|
||||
public static function userSeasonsProvider(): iterable
|
||||
{
|
||||
$user = $this->getUserByEmail('krtek-admin@example.org');
|
||||
yield 'krtek admin' => ['krtek-admin@example.org', 'krtek'];
|
||||
yield 'user1' => ['user1@example.org', 'bbbbb'];
|
||||
}
|
||||
|
||||
#[DataProvider('userSeasonsProvider')]
|
||||
public function testGetSeasonsForUser(string $email, string $expectedSeasonCode): void
|
||||
{
|
||||
$user = $this->getUserByEmail($email);
|
||||
|
||||
$seasons = $this->seasonRepository->getSeasonsForUser($user);
|
||||
$this->assertCount(1, $seasons);
|
||||
$this->assertSame('krtek', $seasons[0]->seasonCode);
|
||||
|
||||
$user = $this->getUserByEmail('user1@example.org');
|
||||
|
||||
$seasons = $this->seasonRepository->getSeasonsForUser($user);
|
||||
$this->assertCount(1, $seasons);
|
||||
$this->assertSame('bbbbb', $seasons[0]->seasonCode);
|
||||
$this->assertSame($expectedSeasonCode, $seasons[0]->seasonCode);
|
||||
}
|
||||
|
||||
public function testUserWithMultipleSeasons(): void
|
||||
|
||||
Reference in New Issue
Block a user