mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 22:35:01 +00:00
PersonAddressMove: fix tests, address history on household, and household::getMembersOnRange
This commit is contained in:
@@ -12,7 +12,6 @@ declare(strict_types=1);
|
||||
namespace Event\Person;
|
||||
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
@@ -27,6 +26,34 @@ use PHPUnit\Framework\TestCase;
|
||||
*/
|
||||
final class PersonAddressMoveEventTest extends TestCase
|
||||
{
|
||||
public function testPersonChangeAddress()
|
||||
{
|
||||
$person = new Person();
|
||||
|
||||
$household = (new Household())->addAddress(
|
||||
($previousAddress = new Address())->setValidFrom(new DateTime('1 year ago'))
|
||||
);
|
||||
$household->addAddress(
|
||||
($nextAddress = new Address())->setValidFrom(new DateTime('1 month ago'))
|
||||
);
|
||||
$member = new HouseholdMember();
|
||||
$member
|
||||
->setPerson($person)
|
||||
->setHousehold($household)
|
||||
->setStartDate(new DateTimeImmutable('1 year ago'))
|
||||
->setEndDate(new DateTimeImmutable('tomorrow'));
|
||||
|
||||
$event = new PersonAddressMoveEvent($person);
|
||||
$event
|
||||
->setPreviousAddress($previousAddress)
|
||||
->setNextAddress($nextAddress);
|
||||
|
||||
$this->assertSame($previousAddress, $event->getPreviousAddress());
|
||||
$this->assertSame($nextAddress, $event->getNextAddress());
|
||||
$this->assertEquals(new DateTime('tomorrow'), $nextAddress->getValidFrom());
|
||||
$this->assertEquals(new DateTime('tomorrow'), $event->getMoveDate());
|
||||
}
|
||||
|
||||
public function testPersonChangeHousehold()
|
||||
{
|
||||
$person = new Person();
|
||||
@@ -88,32 +115,4 @@ final class PersonAddressMoveEventTest extends TestCase
|
||||
$this->assertTrue($event->personLeaveWithoutHousehold());
|
||||
$this->assertEquals(new DateTimeImmutable('tomorrow'), $event->getMoveDate());
|
||||
}
|
||||
|
||||
public function testPersonChangeAddress()
|
||||
{
|
||||
$person = new Person();
|
||||
|
||||
$household = (new Household())->addAddress(
|
||||
($previousAddress = new Address())->setValidFrom(new DateTime('1 year ago'))
|
||||
);
|
||||
$household = (new Household())->addAddress(
|
||||
($nextAddress = new Address())->setValidFrom(new DateTime('1 month ago'))
|
||||
);
|
||||
$member = new HouseholdMember();
|
||||
$member
|
||||
->setPerson($person)
|
||||
->setHousehold($household)
|
||||
->setStartDate(new DateTimeImmutable('1 year ago'))
|
||||
->setEndDate(new DateTimeImmutable('tomorrow'));
|
||||
|
||||
$event = new PersonAddressMoveEvent($person);
|
||||
$event
|
||||
->setPreviousAddress($previousAddress)
|
||||
->setNextAddress($nextAddress);
|
||||
|
||||
$this->assertSame($previousAddress, $event->getPreviousAddress());
|
||||
$this->assertSame($nextAddress, $event->getNextAddress());
|
||||
$this->assertEquals(new DateTime('tomorrow'), $nextAddress->getValidFrom());
|
||||
$this->assertEquals(new DateTime('tomorrow'), $event->getMoveDate());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user