From 6eb8c117a3b097dacda011ba0642ca0940048155 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Tue, 10 Sep 2019 16:30:01 +0200 Subject: [PATCH] Fix tests after reordering has changed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/Service/CardService.php | 3 +++ tests/unit/Service/CardServiceTest.php | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/Service/CardService.php b/lib/Service/CardService.php index 6c72c20bb..406dd75ae 100644 --- a/lib/Service/CardService.php +++ b/lib/Service/CardService.php @@ -402,6 +402,9 @@ class CardService { } $card = $this->cardMapper->find($id); + if ($card->getArchived()) { + throw new StatusException('Operation not allowed. This card is archived.'); + } $card->setStackId($stackId); $this->cardMapper->update($card); diff --git a/tests/unit/Service/CardServiceTest.php b/tests/unit/Service/CardServiceTest.php index b2e2db7ad..641df5dbc 100644 --- a/tests/unit/Service/CardServiceTest.php +++ b/tests/unit/Service/CardServiceTest.php @@ -231,7 +231,10 @@ class CardServiceTest extends TestCase { public function testReorder($cardId, $newPosition, $order) { $cards = $this->getCards(); $cardsTmp = []; - $this->cardMapper->expects($this->at(0))->method('findAll')->willReturn($cards); + $this->cardMapper->expects($this->once())->method('findAll')->willReturn($cards); + $card = new Card(); + $card->setStackId(123); + $this->cardMapper->expects($this->once())->method('find')->willReturn($card); $result = $this->cardService->reorder($cardId, 123, $newPosition); foreach ($result as $card) { $actual[$card->getOrder()] = $card->getId(); @@ -254,7 +257,8 @@ class CardServiceTest extends TestCase { $card = new Card(); $card->setTitle('title'); $card->setArchived(true); - $this->cardMapper->expects($this->once())->method('findAll')->willReturn([$card]); + $card->setStackId(123); + $this->cardMapper->expects($this->once())->method('find')->willReturn($card); $this->cardMapper->expects($this->never())->method('update')->willReturnCallback(function($c) { return $c; }); $this->expectException(StatusException::class); $actual = $this->cardService->reorder(123, 234, 1);