mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-03-06 12:44:20 +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:
56
tests/Repository/CandidateRepositoryTest.php
Normal file
56
tests/Repository/CandidateRepositoryTest.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tvdt\Tests\Repository;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Tvdt\Entity\Candidate;
|
||||
use Tvdt\Repository\CandidateRepository;
|
||||
|
||||
#[CoversClass(CandidateRepository::class)]
|
||||
final class CandidateRepositoryTest extends DatabaseTestCase
|
||||
{
|
||||
/** @return iterable<string, array{0: string}> */
|
||||
public static function candidateHashDataProvider(): iterable
|
||||
{
|
||||
yield 'Normal' => ['Q2xhdWRpYQ'];
|
||||
yield 'lowercase' => ['Y2xhdWRpYQ'];
|
||||
yield 'UPPERCASE' => ['Q0xBVURJQQ'];
|
||||
}
|
||||
|
||||
#[DataProvider('candidateHashDataProvider')]
|
||||
public function testGetCandidateByHash(string $hash): void
|
||||
{
|
||||
$krtekSeason = $this->getSeasonByCode('krtek');
|
||||
$candidate = $this->candidateRepository->getCandidateByHash(
|
||||
$krtekSeason,
|
||||
$hash,
|
||||
);
|
||||
|
||||
$this->assertInstanceOf(Candidate::class, $candidate);
|
||||
|
||||
$this->assertSame('Claudia', $candidate->name);
|
||||
}
|
||||
|
||||
public function testGetCandidateByHashUnknownHashReturnsNull(): void
|
||||
{
|
||||
$krtekSeason = $this->getSeasonByCode('krtek');
|
||||
$result = $this->candidateRepository->getCandidateByHash(
|
||||
$krtekSeason,
|
||||
'TWFyaWpu',
|
||||
);
|
||||
$this->assertNotInstanceOf(Candidate::class, $result);
|
||||
}
|
||||
|
||||
public function testGetCandidateByHashInvalidBase64HashReturnsNull(): void
|
||||
{
|
||||
$krtekSeason = $this->getSeasonByCode('krtek');
|
||||
$result = $this->candidateRepository->getCandidateByHash(
|
||||
$krtekSeason,
|
||||
'TWFyaWpu*',
|
||||
);
|
||||
$this->assertNotInstanceOf(Candidate::class, $result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user