mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-07-11 20:38:21 +02:00
test: address PR review feedback
- Scope AbstractControllerWebTestCase::getCandidate/getQuizByName by season code (both Candidate and Quiz are only unique per season, not system-wide) and add a CandidateRepository regression test guarding against same-named candidates in different seasons - Add missing entityManager->clear() before verifying DB state after a POST in PrepareEliminationControllerTest and QuestionBankControllerTest - Add non-owner denial tests for BackofficeController::exportQuiz and QuizQuestionController::edit/reorder, which had IsGranted checks with no test coverage
This commit is contained in:
@@ -53,4 +53,22 @@ final class CandidateRepositoryTest extends DatabaseTestCase
|
||||
);
|
||||
$this->assertNotInstanceOf(Candidate::class, $result);
|
||||
}
|
||||
|
||||
/** Candidate names are only unique per season, so a same-named candidate in another season must not leak in. */
|
||||
public function testGetCandidateByHashScopesByCandidateSeasonNotJustName(): void
|
||||
{
|
||||
$krtekSeason = $this->getSeasonByCode('krtek');
|
||||
$anotherSeason = $this->getSeasonByCode('bbbbb');
|
||||
|
||||
$duplicateNamedCandidate = new Candidate('Claudia');
|
||||
$anotherSeason->addCandidate($duplicateNamedCandidate);
|
||||
$this->entityManager->persist($duplicateNamedCandidate);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$candidate = $this->candidateRepository->getCandidateByHash($krtekSeason, 'Q2xhdWRpYQ');
|
||||
|
||||
$this->assertInstanceOf(Candidate::class, $candidate);
|
||||
$this->assertSame($krtekSeason, $candidate->season);
|
||||
$this->assertNotSame($duplicateNamedCandidate, $candidate);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user