mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-03-05 20: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
71 lines
2.4 KiB
PHP
71 lines
2.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tvdt\Tests\Repository;
|
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
|
use Tvdt\Entity\Candidate;
|
|
use Tvdt\Entity\Season;
|
|
use Tvdt\Entity\User;
|
|
use Tvdt\Repository\CandidateRepository;
|
|
use Tvdt\Repository\QuestionRepository;
|
|
use Tvdt\Repository\QuizCandidateRepository;
|
|
use Tvdt\Repository\QuizRepository;
|
|
use Tvdt\Repository\SeasonRepository;
|
|
use Tvdt\Repository\UserRepository;
|
|
|
|
abstract class DatabaseTestCase extends KernelTestCase
|
|
{
|
|
protected private(set) EntityManagerInterface $entityManager;
|
|
|
|
protected private(set) CandidateRepository $candidateRepository;
|
|
|
|
protected private(set) QuestionRepository $questionRepository;
|
|
|
|
protected private(set) QuizCandidateRepository $quizCandidateRepository;
|
|
|
|
protected private(set) QuizRepository $quizRepository;
|
|
|
|
protected private(set) SeasonRepository $seasonRepository;
|
|
|
|
protected private(set) UserRepository $userRepository;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->entityManager = self::getContainer()->get(EntityManagerInterface::class);
|
|
|
|
$this->candidateRepository = self::getContainer()->get(CandidateRepository::class);
|
|
$this->questionRepository = self::getContainer()->get(QuestionRepository::class);
|
|
$this->quizCandidateRepository = self::getContainer()->get(QuizCandidateRepository::class);
|
|
$this->quizRepository = self::getContainer()->get(QuizRepository::class);
|
|
$this->seasonRepository = self::getContainer()->get(SeasonRepository::class);
|
|
$this->userRepository = self::getContainer()->get(UserRepository::class);
|
|
}
|
|
|
|
protected function getUserByEmail(string $email): User
|
|
{
|
|
$user = $this->userRepository->findOneBy(['email' => $email]);
|
|
$this->assertInstanceOf(User::class, $user);
|
|
|
|
return $user;
|
|
}
|
|
|
|
protected function getSeasonByCode(string $code): Season
|
|
{
|
|
$season = $this->seasonRepository->findOneBySeasonCode($code);
|
|
$this->assertInstanceOf(Season::class, $season);
|
|
|
|
return $season;
|
|
}
|
|
|
|
protected function getCandidateBySeasonAndName(Season $season, string $name): Candidate
|
|
{
|
|
$candidate = $this->candidateRepository->findOneBy(['season' => $season, 'name' => $name]);
|
|
$this->assertInstanceOf(Candidate::class, $candidate);
|
|
|
|
return $candidate;
|
|
}
|
|
}
|