mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-03-07 05:04:20 +01:00
More tests!
This commit is contained in:
@@ -9,6 +9,7 @@ use Symfony\Component\Console\Attribute\Argument;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Tvdt\Entity\Season;
|
||||
use Tvdt\Repository\SeasonRepository;
|
||||
use Tvdt\Repository\UserRepository;
|
||||
|
||||
@@ -29,7 +30,7 @@ final readonly class ClaimSeasonCommand
|
||||
): int {
|
||||
try {
|
||||
$season = $this->seasonRepository->findOneBySeasonCode($seasonCode);
|
||||
if (null === $season) {
|
||||
if (!$season instanceof Season) {
|
||||
throw new \InvalidArgumentException('Season not found');
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ use Tvdt\Entity\User;
|
||||
final class TestFixtures extends Fixture implements FixtureGroupInterface
|
||||
{
|
||||
public function __construct(
|
||||
private UserPasswordHasherInterface $passwordHasher,
|
||||
private readonly UserPasswordHasherInterface $passwordHasher,
|
||||
) {}
|
||||
|
||||
public static function getGroups(): array
|
||||
|
||||
@@ -7,10 +7,7 @@ namespace Tvdt\Repository;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Tvdt\Entity\Elimination;
|
||||
use Tvdt\Entity\GivenAnswer;
|
||||
use Tvdt\Entity\Quiz;
|
||||
use Tvdt\Entity\QuizCandidate;
|
||||
use Tvdt\Exception\ErrorClearingQuizException;
|
||||
|
||||
/**
|
||||
@@ -29,22 +26,26 @@ class QuizRepository extends ServiceEntityRepository
|
||||
$em = $this->getEntityManager();
|
||||
$em->beginTransaction();
|
||||
try {
|
||||
$em->createQueryBuilder()
|
||||
->delete()->from(QuizCandidate::class, 'qc')
|
||||
->where('qc.quiz = :quiz')
|
||||
$em->createQuery(<<<DQL
|
||||
delete from Tvdt\Entity\QuizCandidate qc
|
||||
where qc.quiz = :quiz
|
||||
DQL)
|
||||
->setParameter('quiz', $quiz)
|
||||
->getQuery()->execute();
|
||||
->execute();
|
||||
|
||||
$em->createQueryBuilder()
|
||||
->delete()->from(GivenAnswer::class, 'ga')
|
||||
->where('ga.quiz = :quiz')
|
||||
$em->createQuery(<<<DQL
|
||||
delete from Tvdt\Entity\GivenAnswer ga
|
||||
where ga.quiz = :quiz
|
||||
DQL)
|
||||
->setParameter('quiz', $quiz)
|
||||
->getQuery()->execute();
|
||||
$em->createQueryBuilder()
|
||||
->delete()->from(Elimination::class, 'e')
|
||||
->where('e.quiz = :quiz')
|
||||
->execute();
|
||||
|
||||
$em->createQuery(<<<DQL
|
||||
delete from Tvdt\Entity\Elimination e
|
||||
where e.quiz = :quiz
|
||||
DQL)
|
||||
->setParameter('quiz', $quiz)
|
||||
->getQuery()->execute();
|
||||
->execute();
|
||||
} catch (\Throwable $throwable) {
|
||||
$this->logger->error($throwable->getMessage());
|
||||
$em->rollback();
|
||||
|
||||
@@ -25,7 +25,7 @@ class SeasonRepository extends ServiceEntityRepository
|
||||
select s from Tvdt\Entity\Season s
|
||||
where s.seasonCode = :seasonCode
|
||||
DQL)
|
||||
->setParameter(':seasonCode', $seasonCode)
|
||||
->setParameter('seasonCode', $seasonCode)
|
||||
->setMaxResults(1)
|
||||
->getOneOrNullResult();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user