fix: draw only active placements on the timeline and keep trips overlapping its dates

This commit is contained in:
fromme committed 2026-11-12 11:13:55 +01:00
1 parent 5ca9b812c3
commit 4e50f23558
6 files changed
+216 -32

No files matched your search

+38 -4
View File
@@ -6,7 +6,10 @@ namespace App\Tests\Repository;
use App\Entity\Assignment;
use App\Entity\Disposition;
use App\Model\AssignmentFilterDto;
use App\Model\TimelineFilterDto;
use App\Repository\AssignmentRepository;
use Carbon\CarbonPeriodImmutable;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
@@ -47,14 +50,45 @@ class AssignmentRepositoryTest extends KernelTestCase
);
}
/**
* The timeline keeps every trip touching its window, so a team on site stays visible when
* the window starts today.
*/
public function testTimelineDateFilterKeepsOverlappingTrips(): void
{
$filterDto = (new TimelineFilterDto())
->setPeriod(CarbonPeriodImmutable::create('2026-11-12', '2026-12-31'))
;
$dql = $this->getRepository()->getListQuery($filterDto)->getDQL();
$this->assertStringContainsString('destination.dateTo >= :dateFrom', $dql);
$this->assertStringContainsString('destination.dateFrom <= :dateTo', $dql);
}
public function testListDateFilterKeepsTripsInsideTheDates(): void
{
$filterDto = (new AssignmentFilterDto())
->setDateFrom(new \DateTimeImmutable('2026-11-12'))
->setDateTo(new \DateTimeImmutable('2026-12-31'))
;
$dql = $this->getRepository()->getListQuery($filterDto)->getDQL();
$this->assertStringContainsString('destination.dateFrom >= :dateFrom', $dql);
$this->assertStringContainsString('destination.dateTo <= :dateTo', $dql);
}
private function createAvailableAssignmentsIdsQuery(): Query
{
return $this->getRepository()->getAvailableAssignmentsIdsQuery();
}
private function getRepository(): AssignmentRepository
{
/** @var EntityManagerInterface $entityManager */
$entityManager = static::getContainer()->get(EntityManagerInterface::class);
/** @var AssignmentRepository $repository */
$repository = $entityManager->getRepository(Assignment::class);
return $repository->getAvailableAssignmentsIdsQuery();
return $entityManager->getRepository(Assignment::class);
}
}