mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-03-06 04:44:19 +01:00
* Some tests * More tests! * Tests 3 * Move getScores from Candidate to Quiz * Add some suggestions for future refactoring * - **Add Gedmo doctrine-extensions and Stof bundle integration** - Added `stof/doctrine-extensions-bundle` and `gedmo/doctrine-extensions` dependencies. - Integrated `Timestampable` behavior for `Created` fields in entities. - Updated `bundles.php` to register StofDoctrineExtensionsBundle. - Added configuration for the Stof bundle. - Simplified `SeasonVoter` with `match` expression and added new tests. - Minor fixes and adjustments across various files. * WIP * All the tests * Base64 tests * Symfomny 7.4.0 * Update * Update recipe * PHP 8.5 * Rector changes * More 8.5 * Things
60 lines
1.9 KiB
PHP
60 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tvdt\Tests\Repository;
|
|
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
use Tvdt\Entity\Season;
|
|
use Tvdt\Repository\SeasonRepository;
|
|
|
|
#[CoversClass(SeasonRepository::class)]
|
|
final class SeasonRepositoryTest extends DatabaseTestCase
|
|
{
|
|
public function testGetSeasonsForUser(): void
|
|
{
|
|
$user = $this->getUserByEmail('krtek-admin@example.org');
|
|
|
|
$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);
|
|
}
|
|
|
|
public function testUserWithMultipleSeasons(): void
|
|
{
|
|
$user = $this->getUserByEmail('user2@example.org');
|
|
$seasons = $this->seasonRepository->getSeasonsForUser($user);
|
|
|
|
$this->assertCount(2, $seasons);
|
|
$this->assertSame('bbbbb', $seasons[0]->seasonCode);
|
|
$this->assertSame('krtek', $seasons[1]->seasonCode);
|
|
}
|
|
|
|
public function testGetSeasonsForUserWithoutSeasonsReturnsEmpty(): void
|
|
{
|
|
$user = $this->getUserByEmail('test@example.org');
|
|
|
|
$seasons = $this->seasonRepository->getSeasonsForUser($user);
|
|
$this->assertEmpty($seasons);
|
|
}
|
|
|
|
public function testFindOneBySeasonCode(): void
|
|
{
|
|
$season = $this->seasonRepository->findOneBySeasonCode('krtek');
|
|
$this->assertInstanceOf(Season::class, $season);
|
|
$this->assertSame('krtek', $season->seasonCode);
|
|
}
|
|
|
|
public function testFindOneBySeasonCodeUnknownSeasonReturnsNull(): void
|
|
{
|
|
$season = $this->seasonRepository->findOneBySeasonCode('invalid');
|
|
$this->assertNotInstanceOf(Season::class, $season);
|
|
}
|
|
}
|