mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
add link to household or household editor
This commit is contained in:
@@ -22,6 +22,9 @@
|
||||
|
||||
namespace Chill\PersonBundle\Tests\Entity;
|
||||
|
||||
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||
use Chill\PersonBundle\Entity\Household\Position;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
@@ -205,4 +208,39 @@ class PersonTest extends \PHPUnit\Framework\TestCase
|
||||
$this::assertEquals($address3, $p->getLastAddress($addressDate3));
|
||||
}
|
||||
|
||||
public function testIsSharingHousehold()
|
||||
{
|
||||
$person = new Person();
|
||||
$household = new Household();
|
||||
$positionShare = (new Position())
|
||||
->setShareHousehold(true);
|
||||
$positionNotShare = (new Position())
|
||||
->setShareHousehold(false);
|
||||
|
||||
$membership1 = (new HouseholdMember())
|
||||
->setStartDate(new \DateTimeImmutable('10 years ago'))
|
||||
->setEndDate(new \DateTimeImmutable('5 years ago'))
|
||||
->setPerson($person)
|
||||
->setPosition($positionShare)
|
||||
;
|
||||
$household->addMember($membership1);
|
||||
|
||||
$membership2 = (new HouseholdMember())
|
||||
->setStartDate(new \DateTimeImmutable('4 years ago'))
|
||||
->setEndDate(new \DateTimeImmutable('2 years ago'))
|
||||
->setPerson($person)
|
||||
->setPosition($positionNotShare)
|
||||
;
|
||||
$household->addMember($membership2);
|
||||
|
||||
$this->assertEquals(2, $person->getHouseholdParticipations()
|
||||
->count());
|
||||
|
||||
$this->assertFalse($person->isSharingHousehold());
|
||||
$this->assertTrue($person->isSharingHousehold(
|
||||
new \DateTimeImmutable('6 years ago')));
|
||||
$this->assertFalse($person->isSharingHousehold(
|
||||
new \DateTimeImmutable('3 years ago')));
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user