Work on test, but still fails

This commit is contained in:
Julie Lenaerts 2023-09-21 16:18:51 +02:00
parent 260a173a61
commit 29983cc2ad

View File

@ -20,16 +20,13 @@ class AccompanyingCourseExportHelperTest extends KernelTestCase
private EntityManagerInterface $em;
private EntityRepository $repository;
private AccompanyingCourseExportHelper $accompanyingCourseExportHelper;
protected function setUp(): void
{
self::bootKernel();
$this->em = self::$container->get(EntityManagerInterface::class);
$this->repository = self::$container->get($this->em->getRepository(AccompanyingPeriod::class));
$this->accompanyingPeriodExportHelper = self::$container->get(AccompanyingCourseExportHelper::class);
$this->accompanyingCourseExportHelper = self::$container->get(AccompanyingCourseExportHelper::class);
}
public static function tearDownAfterClass(): void
@ -57,14 +54,19 @@ class AccompanyingCourseExportHelperTest extends KernelTestCase
AccompanyingPeriod $periodC // canceled (child cm of canceled cm)
): void
{
$qb = $this->repository->createQueryBuilder('acp');
$qb->select('acp.id')->from(AccompanyingPeriod::class, 'acp');
$qb = $this->em->getRepository(AccompanyingPeriod::class)->createQueryBuilder('acp');
$this->accompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
$qb->select('acp.id');
$periodIdsFound = $qb->getQuery()->getResult();
$periodA = $this->em->find(AccompanyingPeriod::class, $periodA->getId());
$periodB = $this->em->find(AccompanyingPeriod::class, $periodB->getId());
$periodC = $this->em->find(AccompanyingPeriod::class, $periodC->getId());
self::assertContains($periodB->getId(), $periodIdsFound, 'Period without canceled closing motive has been found');
self::assertNotContains($periodA->getId(), $periodIdsFound, 'Period with canceled closing motive has not been found');
self::assertNotContains($periodA->getdId(), $periodIdsFound, 'Period with canceled closing motive has not been found');
self::assertNotContains($periodC->getId(), $periodIdsFound, 'Period with child canceled closing motive has not been found');
}
@ -97,15 +99,15 @@ class AccompanyingCourseExportHelperTest extends KernelTestCase
$this->em->persist($periodB);
$this->em->persist($periodC);
self::$entitiesToDelete[] = [ClosingMotive::class, $cmChild];
self::$entitiesToDelete[] = [ClosingMotive::class, $cmA];
self::$entitiesToDelete[] = [ClosingMotive::class, $cmB];
self::$entitiesToDelete[] = [ClosingMotive::class, $cmChild];
self::$entitiesToDelete[] = [AccompanyingPeriod::class, $periodA];
self::$entitiesToDelete[] = [AccompanyingPeriod::class, $periodB];
self::$entitiesToDelete[] = [AccompanyingPeriod::class, $periodC];
yield [$periodA, $periodB, $periodC];
yield [$periodA, $periodB, $periodC, 'Verify that period with non-canceling closing motive is found'];
$this->em->flush();
$this->em->clear();