mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 23:23:51 +00:00
Fix: force the consistency of location in accompanying period
- internally, the entity remove the addressLocation when the personLocation is set, and vice-versa; - this commit add a migration which may solve the case when both case happens (priority to personLocation + keep the history) - add a constraint on the database to avoid such situation
This commit is contained in:
@@ -138,12 +138,14 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
|
||||
$this->assertCount(1, $period->getLocationHistories());
|
||||
|
||||
$this->assertSame($address, $period->getLocationHistories()->first()->getAddressLocation());
|
||||
$this->assertNull($period->getLocationHistories()->first()->getPersonLocation());
|
||||
|
||||
$period->setPersonLocation($person);
|
||||
$period->setAddressLocation(null);
|
||||
|
||||
$this->assertCount(2, $period->getLocationHistories());
|
||||
$this->assertSame($person, $period->getLocationHistories()->last()->getPersonLocation());
|
||||
$this->assertNull($period->getLocationHistories()->last()->getAddressLocation());
|
||||
|
||||
$period->setAddressLocation($address);
|
||||
$period->setPersonLocation(null);
|
||||
@@ -172,14 +174,35 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
|
||||
} while ($iterator->valid());
|
||||
}
|
||||
|
||||
public function testIsClosed()
|
||||
{
|
||||
$period = new AccompanyingPeriod(new DateTime());
|
||||
$period->setClosingDate(new DateTime('tomorrow'));
|
||||
|
||||
$this->assertFalse($period->isOpen());
|
||||
public function testHistoryLocationNotHavingBothAtStart()
|
||||
{
|
||||
$period = new AccompanyingPeriod();
|
||||
$person = new Person();
|
||||
$address = new Address();
|
||||
|
||||
$period->setAddressLocation($address);
|
||||
$period->setPersonLocation($person);
|
||||
|
||||
$period->setStep(AccompanyingPeriod::STEP_CONFIRMED);
|
||||
|
||||
$this->assertCount(1, $period->getLocationHistories());
|
||||
|
||||
self::assertNull($period->getAddressLocation());
|
||||
self::assertNull($period->getLocationHistories()->first()->getAddressLocation());
|
||||
self::assertSame($person, $period->getLocationHistories()->first()->getPersonLocation());
|
||||
self::assertSame($person, $period->getPersonLocation());
|
||||
self::assertEquals('person', $period->getLocationStatus());
|
||||
}
|
||||
|
||||
public function testIsClosed()
|
||||
{
|
||||
$period = new AccompanyingPeriod(new DateTime());
|
||||
$period->setClosingDate(new DateTime('tomorrow'));
|
||||
|
||||
$this->assertFalse($period->isOpen());
|
||||
}
|
||||
|
||||
public function testIsOpen()
|
||||
{
|
||||
$period = new AccompanyingPeriod(new DateTime());
|
||||
|
Reference in New Issue
Block a user