From 9a7bcafa6c7f937f8e6b386b0d592f427399c7d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Mon, 29 Nov 2021 20:31:00 +0100 Subject: [PATCH] Properly handle setters now that there is a default value of null with unset acl/labels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/Db/Board.php | 8 ++------ tests/unit/Db/BoardMapperTest.php | 1 + 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/Db/Board.php b/lib/Db/Board.php index 9125c2ca7..6cf3c3206 100644 --- a/lib/Db/Board.php +++ b/lib/Db/Board.php @@ -74,18 +74,14 @@ class Board extends RelationalEntity { * @param Label[] $labels */ public function setLabels($labels) { - foreach ($labels as $l) { - $this->labels[] = $l; - } + $this->labels = $labels; } /** * @param Acl[] $acl */ public function setAcl($acl) { - foreach ($acl as $a) { - $this->acl[] = $a; - } + $this->acl = $acl; } public function getETag() { diff --git a/tests/unit/Db/BoardMapperTest.php b/tests/unit/Db/BoardMapperTest.php index 78cc0cccc..43060db79 100644 --- a/tests/unit/Db/BoardMapperTest.php +++ b/tests/unit/Db/BoardMapperTest.php @@ -161,6 +161,7 @@ class BoardMapperTest extends MapperTestUtility { $actual = $this->boardMapper->find($this->boards[0]->getId(), true, false); /** @var Board $expected */ $expected = $this->boards[0]; + $expected->setLabels([]); $this->assertEquals($expected->getLabels(), $actual->getLabels()); }