mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
handle event PersonMoveEvent on Period
This commit is contained in:
@@ -39,49 +39,6 @@ final class MembersEditorTest extends TestCase
|
||||
$this->factory = $this->buildMembersEditorFactory();
|
||||
}
|
||||
|
||||
private function buildMembersEditorFactory(
|
||||
?EventDispatcherInterface $eventDispatcher = null,
|
||||
?ValidatorInterface $validator = null
|
||||
) {
|
||||
if ($eventDispatcher === null) {
|
||||
$double = $this->getProphet()->prophesize();
|
||||
$double->willImplement(EventDispatcherInterface::class);
|
||||
$double->dispatch(Argument::type(PersonAddressMoveEvent::class));
|
||||
$eventDispatcher = $double->reveal();
|
||||
}
|
||||
|
||||
if ($validator === null) {
|
||||
$double = $this->getProphet()->prophesize();
|
||||
$double->willImplement(ValidatorInterface::class);
|
||||
$validator = $double->reveal();
|
||||
}
|
||||
|
||||
return new MembersEditorFactory(
|
||||
$eventDispatcher, $validator
|
||||
);
|
||||
}
|
||||
|
||||
public function testPostMove()
|
||||
{
|
||||
$person = new Person();
|
||||
$position = (new Position())
|
||||
->setShareHousehold(false);
|
||||
$household1 = new Household();
|
||||
$household2 = new Household();
|
||||
$eventDispatcher = $this->prophesize(EventDispatcherInterface::class);
|
||||
$eventDispatcher
|
||||
->dispatch(Argument::type(PersonAddressMoveEvent::class))
|
||||
->shouldBeCalled();
|
||||
$factory = $this->buildMembersEditorFactory(
|
||||
$eventDispatcher->reveal(), null
|
||||
);
|
||||
$editor = $factory->createEditor($household1);
|
||||
|
||||
$editor->addMovement(new DateTimeImmutable('now'), $person, $position);
|
||||
|
||||
$editor->postMove();
|
||||
}
|
||||
|
||||
public function testMovePersonWithoutSharedHousehold()
|
||||
{
|
||||
$person = new Person();
|
||||
@@ -168,4 +125,49 @@ final class MembersEditorTest extends TestCase
|
||||
);
|
||||
$this->assertEquals($date, $membership1->getEndDate());
|
||||
}
|
||||
|
||||
public function testPostMove()
|
||||
{
|
||||
$person = new Person();
|
||||
$position = (new Position())
|
||||
->setShareHousehold(false);
|
||||
$household1 = new Household();
|
||||
$household2 = new Household();
|
||||
$eventDispatcher = $this->prophesize(EventDispatcherInterface::class);
|
||||
$eventDispatcher
|
||||
->dispatch(Argument::type(PersonAddressMoveEvent::class))
|
||||
->shouldBeCalled();
|
||||
$factory = $this->buildMembersEditorFactory(
|
||||
$eventDispatcher->reveal(),
|
||||
null
|
||||
);
|
||||
$editor = $factory->createEditor($household1);
|
||||
|
||||
$editor->addMovement(new DateTimeImmutable('now'), $person, $position);
|
||||
|
||||
$editor->postMove();
|
||||
}
|
||||
|
||||
private function buildMembersEditorFactory(
|
||||
?EventDispatcherInterface $eventDispatcher = null,
|
||||
?ValidatorInterface $validator = null
|
||||
) {
|
||||
if (null === $eventDispatcher) {
|
||||
$double = $this->getProphet()->prophesize();
|
||||
$double->willImplement(EventDispatcherInterface::class);
|
||||
$double->dispatch(Argument::type(PersonAddressMoveEvent::class));
|
||||
$eventDispatcher = $double->reveal();
|
||||
}
|
||||
|
||||
if (null === $validator) {
|
||||
$double = $this->getProphet()->prophesize();
|
||||
$double->willImplement(ValidatorInterface::class);
|
||||
$validator = $double->reveal();
|
||||
}
|
||||
|
||||
return new MembersEditorFactory(
|
||||
$eventDispatcher,
|
||||
$validator
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user