diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index 8b60888bd..9eec8e6fb 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -401,7 +401,7 @@ class AccompanyingPeriod { $participation = $this->getOpenParticipationContainsPerson($person); - if (! null === $participation) { + if ($participation instanceof AccompanyingPeriodParticipation) { $participation->setEndDate(new \DateTimeImmutable('now')); } diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index 464be5f31..3624d4c17 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -390,7 +390,7 @@ class Person implements HasCenterInterface * * @deprecated since 1.1 use `getOpenedAccompanyingPeriod instead */ - public function getCurrentAccompanyingPeriod() : AccompanyingPeriod + public function getCurrentAccompanyingPeriod() : ?AccompanyingPeriod { return $this->getOpenedAccompanyingPeriod(); } @@ -1011,7 +1011,7 @@ class Person implements HasCenterInterface * By default, the addresses are ordered by date, descending (the most * recent first) */ - public function getAddresses(): ArrayCollection + public function getAddresses(): Collection { return $this->addresses; } diff --git a/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php b/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php index a1d13892f..03fddab41 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php @@ -79,19 +79,27 @@ class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase public function testPersonPeriod() { $person = new Person(); + $person2 = new Person(); + $person3 = new Person(); $period = new AccompanyingPeriod(new \DateTime()); $period->addPerson($person); + $period->addPerson($person2); + $period->addPerson($person3); - $this->assertEquals(1, $period->getParticipations()->count()); + $this->assertEquals(3, $period->getParticipations()->count()); $this->assertTrue($period->containsPerson($person)); + $this->assertFalse($period->containsPerson(new Person())); $participation = $period->getOpenParticipationContainsPerson($person); $participations = $period->getParticipationsContainsPerson($person); $this->assertNotNull($participation); + $this->assertSame($person, $participation->getPerson()); $this->assertEquals(1, $participations->count()); - $period->removePerson($person); + $participationL = $period->removePerson($person); + $this->assertSame($participationL, $participation); + $this->assertTrue($participation->getEndDate() instanceof \DateTimeInterface); $participation = $period->getOpenParticipationContainsPerson($person); $this->assertNull($participation);