fix: called-off dispositions no longer block teamers

This commit is contained in:
Björn Fromme
2026-08-26 09:11:27 +02:00
committed by fromme
parent cc280907e5
commit f3eae5462d
8 changed files with 186 additions and 20 deletions
@@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
namespace App\Tests\Repository;
use App\Entity\Assignment;
use App\Entity\Disposition;
use App\Repository\AssignmentRepository;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
/**
* The slot counting behind every teamer facing assignment list lives in DQL, so the query is
* compiled here and the parts carrying the semantics are pinned.
*/
class AssignmentRepositoryTest extends KernelTestCase
{
public function testAvailableAssignmentsQueryIgnoresCalledOffDispositions(): void
{
$dql = $this->createAvailableAssignmentsIdsQuery()->getDQL();
// the exclusion has to live in the JOIN condition: moved into the WHERE clause it would
// drop assignments without any disposition at all
$this->assertStringContainsString(
'LEFT JOIN assignment.dispositions disposition WITH disposition.status <> :dispositionCalledOff',
$dql
);
$this->assertStringContainsString(
'HAVING assignment.availableDispositions > COUNT(disposition.id)',
$dql
);
}
public function testAvailableAssignmentsQueryBindsTheCalledOffStatuses(): void
{
$query = $this->createAvailableAssignmentsIdsQuery();
$this->assertSame(
Disposition::STATUS_CALLED_OFF,
$query->getParameter('dispositionCalledOff')->getValue()
);
$this->assertSame(
[Assignment::STATUS_DRAFT, Assignment::STATUS_CALLED_OFF],
$query->getParameter('status')->getValue()
);
}
private function createAvailableAssignmentsIdsQuery(): Query
{
/** @var EntityManagerInterface $entityManager */
$entityManager = static::getContainer()->get(EntityManagerInterface::class);
/** @var AssignmentRepository $repository */
$repository = $entityManager->getRepository(Assignment::class);
return $repository->getAvailableAssignmentsIdsQuery();
}
}