notification: add test for unread consistency

This commit is contained in:
2021-12-26 01:12:32 +01:00
parent bd3919efcb
commit 700bb02374
3 changed files with 31 additions and 2 deletions

View File

@@ -92,7 +92,7 @@ class Notification
public function addUnreadBy(User $user): self
{
if (!$this->unreadBy->contains($user)) {
$this->unreadBy->add($user);
$this->unreadBy[] = $user;
}
return $this;
@@ -136,6 +136,11 @@ class Notification
return $this->sender;
}
public function getUnreadBy(): Collection
{
return $this->unreadBy;
}
public function isReadBy(User $user): bool
{
return !$this->unreadBy->contains($user);
@@ -154,7 +159,7 @@ class Notification
public function removeAddressee(User $addressee): self
{
$this->addressees->removeElement($addressee);
$this->unreadBy->removeElement($addressee);
$this->removeUnreadBy($addressee);
return $this;
}