WIP [centerHistory] Try to get test to work for personCenterHistory

This commit is contained in:
2023-08-03 11:40:47 +02:00
parent fd79692f6d
commit 3af065e530
3 changed files with 37 additions and 15 deletions

View File

@@ -85,20 +85,38 @@ class PersonMoveTest extends KernelTestCase
$centerA = ($this->em->getRepository(Center::class))->find(1);
$centerB = ($this->em->getRepository(Center::class))->find(2);
$personCenterHistoryAFirst = (new Person\PersonCenterHistory())->setPerson($personA)->setCenter($centerA)->setStartDate(new \DateTimeImmutable('2023-01-01'))->setEndDate(new \DateTimeImmutable('2023-06-30'));
$personCenterHistoryASecond = (new Person\PersonCenterHistory())->setPerson($personA)->setCenter($centerB)->setStartDate(new \DateTimeImmutable('2023-06-30'))->setEndDate(new \DateTimeImmutable('2023-09-30'));
$personCenterHistoryBFirst = (new Person\PersonCenterHistory())->setPerson($personB)->setCenter($centerA)->setStartDate(new \DateTimeImmutable('2023-01-01'))->setEndDate(new \DateTimeImmutable('2023-07-15'));
$personCenterHistoryBSecond = (new Person\PersonCenterHistory())->setPerson($personB)->setCenter($centerB)->setStartDate(new \DateTimeImmutable('2023-07-15'))->setEndDate(new \DateTimeImmutable('2023-09-30'));
$this->em->persist($personA);
$this->em->persist($personB);
$personCenterHistoryAFirst = (new Person\PersonCenterHistory())->setCenter($centerA)->setStartDate(new \DateTimeImmutable('2023-01-01'))->setEndDate(new \DateTimeImmutable('2023-06-30'));
$personCenterHistoryASecond = (new Person\PersonCenterHistory())->setCenter($centerB)->setStartDate(new \DateTimeImmutable('2023-06-30'))->setEndDate(new \DateTimeImmutable('2023-09-30'));
$personCenterHistoryBFirst = (new Person\PersonCenterHistory())->setCenter($centerA)->setStartDate(new \DateTimeImmutable('2023-01-01'))->setEndDate(new \DateTimeImmutable('2023-07-15'));
$personCenterHistoryBSecond = (new Person\PersonCenterHistory())->setCenter($centerB)->setStartDate(new \DateTimeImmutable('2023-07-15'))->setEndDate(new \DateTimeImmutable('2023-09-30'));
// $personA->getCenterHistory()->add($personCenterHistoryAFirst);
// $personA->getCenterHistory()->add($personCenterHistoryASecond);
// $personB->getCenterHistory()->add($personCenterHistoryBFirst);
// $personB->getCenterHistory()->add($personCenterHistoryBSecond);
// $personCenterHistoryAFirst->setPerson($personA);
// $personCenterHistoryASecond->setPerson($personA);
// $personCenterHistoryBFirst->setPerson($personB);
// $personCenterHistoryBSecond->setPerson($personB);
$this->em->persist($personCenterHistoryAFirst);
$this->em->persist($personCenterHistoryASecond);
$this->em->persist($personCenterHistoryBFirst);
$this->em->persist($personCenterHistoryBSecond);
$personA->addCenterHistory($personCenterHistoryAFirst);
$personA->addCenterHistory($personCenterHistoryASecond);
$personB->addCenterHistory($personCenterHistoryBFirst);
$personB->addCenterHistory($personCenterHistoryBSecond);
$this->em->flush();
// $this->em->refresh($personA);
// $this->em->refresh($personB);
$this->em->clear();
$move = new PersonMove($this->em, $this->personMoveManager, $this->eventDispatcher);
@@ -112,13 +130,10 @@ class PersonMoveTest extends KernelTestCase
$personA = $this->em->find(Person::class, $personA->getId());
$personB = $this->em->find(Person::class, $personB->getId());
$remainingCenterHistory = $this->em->getRepository(Person\PersonCenterHistory::class)->findBy(['person' => $personB]);
$message = 'Move persons with overlapping center histories';
self::assertNull($personA?->getId(), $message);
self::assertNotNull($personB?->getId(), $message);
self::assertEquals(new \DateTimeImmutable('2023-01-01'), $remainingCenterHistory->getStartDate());
self::$entitiesToDelete[] = [Person::class, $personA];
self::$entitiesToDelete[] = [Person::class, $personB];