fix test which randomly failed

This commit is contained in:
2021-06-18 13:30:31 +02:00
parent 0e9933ca41
commit 7a6117a264
2 changed files with 80 additions and 16 deletions

View File

@@ -1264,15 +1264,24 @@ class Person implements HasCenterInterface
}
public function getCurrentHousehold(?\DateTimeImmutable $at = null): ?Household
{
$participation = $this->getCurrentHouseholdParticipationShareHousehold($at);
return $participation instanceof HouseholdMember ?
$participation->getHousehold()
: null;
}
public function getCurrentHouseholdParticipationShareHousehold(?\DateTimeImmutable $at = null): ?HouseholdMember
{
$criteria = new Criteria();
$expr = Criteria::expr();
$date = NULL === $at ? new \DateTimeImmutable('now') : $at;
$date = NULL === $at ? new \DateTimeImmutable('today') : $at;
$datef = $date->format('Y-m-d');
if (
NULL !== ($this->currentHouseholdAt[$datef] ?? NULL)) {
return $this->currentHouseholdAt[$datef];
NULL !== ($this->currentHouseholdParticipationAt[$datef] ?? NULL)) {
return $this->currentHouseholdParticipationAt[$datef];
}
$criteria
@@ -1281,7 +1290,7 @@ class Person implements HasCenterInterface
$expr->lte('startDate', $date),
$expr->orX(
$expr->isNull('endDate'),
$expr->gte('endDate', $date)
$expr->gt('endDate', $date)
),
$expr->eq('shareHousehold', true)
)
@@ -1292,8 +1301,7 @@ class Person implements HasCenterInterface
;
return $participations->count() > 0 ?
$this->currentHouseholdAt[$datef] = $participations->first()
->getHousehold()
$this->currentHouseholdParticipationAt[$datef] = $participations->first()
: null;
}