mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
add tests for moving to not share position in another household
This commit is contained in:
parent
1b567327b7
commit
3b083c31e7
@ -40,6 +40,48 @@ final class MembersEditorTest extends TestCase
|
||||
$this->factory = $this->buildMembersEditorFactory();
|
||||
}
|
||||
|
||||
/**
|
||||
* We test here a move for a person:.
|
||||
*
|
||||
* * which was in a position "sharing household"
|
||||
* * which move to the another household, in a position "not sharing household"
|
||||
*
|
||||
* The person should stays in the two households
|
||||
*/
|
||||
public function testMoveFromSharingHouseholdToNotSharingHousehouldInDifferentHousehold()
|
||||
{
|
||||
$person = new Person();
|
||||
$household = new Household();
|
||||
$positionSharing = (new Position())->setShareHousehold(true);
|
||||
$positionNotSharing = (new Position())->setShareHousehold(false);
|
||||
$factory = $this->buildMembersEditorFactory();
|
||||
$editor = $factory->createEditor($household);
|
||||
|
||||
// we add the member to the household
|
||||
$editor->addMovement(new DateTimeImmutable('1 month ago'), $person, $positionSharing);
|
||||
|
||||
// double check that the person is in the household
|
||||
$this->assertContains($person, $household->getCurrentPersons());
|
||||
|
||||
// we do the move to the position not sharing household
|
||||
$editor = $factory->createEditor($household2 = new Household());
|
||||
$editor->addMovement(new DateTimeImmutable('yesterday'), $person, $positionNotSharing);
|
||||
|
||||
$sharings = $household->getCurrentMembers()->filter(static function (HouseholdMember $m) {
|
||||
return $m->getShareHousehold();
|
||||
});
|
||||
$notSharing = $household2->getCurrentMembers()->filter(static function (HouseholdMember $m) {
|
||||
return !$m->getShareHousehold();
|
||||
});
|
||||
|
||||
$this->assertCount(1, $notSharing);
|
||||
$this->assertCount(1, $sharings);
|
||||
|
||||
$getPerson = static function (HouseholdMember $m) { return $m->getPerson(); };
|
||||
|
||||
$this->assertContains($person, $notSharing->map($getPerson));
|
||||
}
|
||||
|
||||
/**
|
||||
* We test here a move for a person:.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user