feat: all-season assignments

This commit is contained in:
Björn Fromme authored and Björn Fromme committed 2026-09-26 12:13:16 +02:00
1 parent 675cec1b69
commit cf876ed224
119 files changed
+6194 -294

No files matched your search

+82
View File
@@ -0,0 +1,82 @@
<?php
declare(strict_types=1);
namespace App\Tests\Repository;
use App\Model\TeamerFilterDto;
use App\Repository\TeamerRepository;
use Doctrine\ORM\QueryBuilder;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
/**
* The all-season list is the ordinary teamer list under a scope, so what separates the two is a
* single condition in the shared query builder. Compiled here so the scope cannot quietly stop
* being applied - an unscoped "Saisonteamer" list would silently show the whole team.
*/
class TeamerRepositoryTest extends KernelTestCase
{
public function testTheScopedListRestrictsToAllSeasonTeamers(): void
{
$query = $this->getRepository()->getListQuery((new TeamerFilterDto())->setAllSeason(true));
$this->assertStringContainsString('teamer.allSeason = :allSeason', $query->getDQL());
$this->assertTrue($query->getParameter('allSeason')->getValue());
}
public function testTheGeneralListIsNotRestricted(): void
{
$query = $this->getRepository()->getListQuery(new TeamerFilterDto());
$this->assertStringNotContainsString('teamer.allSeason', $query->getDQL());
$this->assertNull($query->getParameter('allSeason'));
}
/**
* The mailing resolves its recipients through the same builder, so a mailing started from
* the all-season list must not be able to reach the rest of the team.
*/
public function testTheMailingRecipientsCarryTheSameScope(): void
{
$repository = $this->getRepository();
$reflection = new \ReflectionMethod($repository, 'createListQueryBuilder');
$queryBuilder = $reflection->invoke($repository, (new TeamerFilterDto())->setAllSeason(true));
$this->assertStringContainsString('teamer.allSeason = :allSeason', $queryBuilder->getDQL());
}
/**
* The season assignment form picks its teamer through this endpoint, so an unrestricted
* suggestion list would let an admin place a short term teamer on a season assignment.
*/
public function testTheAutocompleteCanBeRestrictedToAllSeasonTeamers(): void
{
$dql = $this->createAutocompletionQueryBuilder(true)->getDQL();
$this->assertStringContainsString('teamer.allSeason = :allSeason', $dql);
}
public function testTheAutocompleteIsUnrestrictedByDefault(): void
{
$dql = $this->createAutocompletionQueryBuilder(false)->getDQL();
$this->assertStringNotContainsString('teamer.allSeason', $dql);
$this->assertStringContainsString('teamer.deletedAt IS NULL', $dql);
}
private function createAutocompletionQueryBuilder(bool $allSeasonOnly): QueryBuilder
{
$repository = $this->getRepository();
$reflection = new \ReflectionMethod($repository, 'createAutocompletionQueryBuilder');
return $reflection->invoke($repository, '', $allSeasonOnly);
}
private function getRepository(): TeamerRepository
{
self::bootKernel();
return self::getContainer()->get(TeamerRepository::class);
}
}