mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-03-06 04:44:19 +01:00
Create Testcoverage and upgrade Symfomy and PHP
* 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
This commit is contained in:
72
tests/Repository/QuizCandidateRepositoryTest.php
Normal file
72
tests/Repository/QuizCandidateRepositoryTest.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tvdt\Tests\Repository;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use Tvdt\Entity\Quiz;
|
||||
use Tvdt\Entity\QuizCandidate;
|
||||
use Tvdt\Repository\QuizCandidateRepository;
|
||||
|
||||
#[CoversClass(QuizCandidateRepository::class)]
|
||||
final class QuizCandidateRepositoryTest extends DatabaseTestCase
|
||||
{
|
||||
public function testCreateIfNotExists(): void
|
||||
{
|
||||
$krtekSeason = $this->getSeasonByCode('krtek');
|
||||
$candidate = $this->getCandidateBySeasonAndName($krtekSeason, 'Myrthe');
|
||||
$quiz = $krtekSeason->activeQuiz;
|
||||
$this->assertInstanceOf(Quiz::class, $quiz);
|
||||
|
||||
$result = $this->quizCandidateRepository->createIfNotExist($quiz, $candidate);
|
||||
$this->assertTrue($result);
|
||||
|
||||
$quizCandidate = $this->quizCandidateRepository->findOneBy([
|
||||
'candidate' => $candidate,
|
||||
'quiz' => $quiz,
|
||||
]);
|
||||
|
||||
$this->assertInstanceOf(QuizCandidate::class, $quizCandidate);
|
||||
|
||||
$result = $this->quizCandidateRepository->createIfNotExist($quiz, $candidate);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
public function testSetCorrectionsForCandidateUpdatesCandidateCorrectly(): void
|
||||
{
|
||||
$krtekSeason = $this->getSeasonByCode('krtek');
|
||||
$candidate = $this->getCandidateBySeasonAndName($krtekSeason, 'Myrthe');
|
||||
$quiz = $krtekSeason->activeQuiz;
|
||||
$this->assertInstanceOf(Quiz::class, $quiz);
|
||||
|
||||
$this->quizCandidateRepository->createIfNotExist($quiz, $candidate);
|
||||
|
||||
$this->quizCandidateRepository->setCorrectionsForCandidate(
|
||||
$quiz, $candidate, 3.5,
|
||||
);
|
||||
|
||||
$quizCandidate = $this->quizCandidateRepository->findOneBy([
|
||||
'candidate' => $candidate,
|
||||
'quiz' => $quiz,
|
||||
]);
|
||||
|
||||
$this->assertInstanceOf(QuizCandidate::class, $quizCandidate);
|
||||
|
||||
$this->assertEqualsWithDelta(3.5, $quizCandidate->corrections, 0.1);
|
||||
}
|
||||
|
||||
public function testCannotGiveCorrectionsToCandidateWithoutResult(): void
|
||||
{
|
||||
$krtekSeason = $this->getSeasonByCode('krtek');
|
||||
$candidate = $this->getCandidateBySeasonAndName($krtekSeason, 'Myrthe');
|
||||
$quiz = $krtekSeason->activeQuiz;
|
||||
$this->assertInstanceOf(Quiz::class, $quiz);
|
||||
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
|
||||
$this->quizCandidateRepository->setCorrectionsForCandidate(
|
||||
$quiz, $candidate, 3.5,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user