mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
do not launch PersonMoveEvent when moving to the same household
This commit is contained in:
@@ -231,13 +231,71 @@ final class MembersEditorTest extends TestCase
|
||||
$editor->postMove();
|
||||
}
|
||||
|
||||
public function testPostMoveToAPositionSharingHousehold()
|
||||
public function testPostMoveToAPositionSharingHouseholdAndSameHousehold()
|
||||
{
|
||||
$person = new Person();
|
||||
$position = (new Position())
|
||||
->setShareHousehold(true);
|
||||
$position2 = (new Position())
|
||||
->setShareHousehold(true);
|
||||
$household1 = new Household();
|
||||
|
||||
// set into the first household
|
||||
$editor = $this->buildMembersEditorFactory()
|
||||
->createEditor($household1);
|
||||
$editor->addMovement(new DateTimeImmutable('1 year ago'), $person, $position);
|
||||
|
||||
// prepare for next move
|
||||
$eventDispatcher = $this->prophesize(EventDispatcherInterface::class);
|
||||
$eventDispatcher
|
||||
->dispatch(Argument::type(PersonAddressMoveEvent::class))
|
||||
->shouldNotBeCalled();
|
||||
$factory = $this->buildMembersEditorFactory(
|
||||
$eventDispatcher->reveal(),
|
||||
null
|
||||
);
|
||||
$editor = $factory->createEditor($household1);
|
||||
|
||||
$editor->addMovement(new DateTimeImmutable('now'), $person, $position2);
|
||||
|
||||
$editor->postMove();
|
||||
}
|
||||
|
||||
public function testPostMoveToAPositionSharingHouseholdFromDifferentHousehold()
|
||||
{
|
||||
$person = new Person();
|
||||
$position = (new Position())
|
||||
->setShareHousehold(true);
|
||||
$household1 = new Household();
|
||||
$household2 = new Household();
|
||||
|
||||
// set into the first household
|
||||
$editor = $this->buildMembersEditorFactory()
|
||||
->createEditor($household1);
|
||||
$editor->addMovement(new DateTimeImmutable('1 year ago'), $person, $position);
|
||||
|
||||
// perform now the movement
|
||||
$eventDispatcher = $this->prophesize(EventDispatcherInterface::class);
|
||||
$eventDispatcher
|
||||
->dispatch(Argument::type(PersonAddressMoveEvent::class))
|
||||
->shouldBeCalled();
|
||||
$factory = $this->buildMembersEditorFactory(
|
||||
$eventDispatcher->reveal(),
|
||||
null
|
||||
);
|
||||
$editor = $factory->createEditor($household2);
|
||||
|
||||
$editor->addMovement(new DateTimeImmutable('now'), $person, $position);
|
||||
|
||||
$editor->postMove();
|
||||
}
|
||||
|
||||
public function testPostMoveToAPositionSharingHouseholdFromNoHousehold()
|
||||
{
|
||||
$person = new Person();
|
||||
$position = (new Position())
|
||||
->setShareHousehold(true);
|
||||
$household1 = new Household();
|
||||
$eventDispatcher = $this->prophesize(EventDispatcherInterface::class);
|
||||
$eventDispatcher
|
||||
->dispatch(Argument::type(PersonAddressMoveEvent::class))
|
||||
|
Reference in New Issue
Block a user