Skip to content

Commit

Permalink
Fix tests after reordering has changed
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Sep 10, 2019
1 parent f74a3d6 commit 6eb8c11
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/Service/CardService.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,9 @@ public function reorder($id, $stackId, $order) {
}

$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);

Expand Down
8 changes: 6 additions & 2 deletions tests/unit/Service/CardServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,10 @@ public function dataReorder() {
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();
Expand All @@ -254,7 +257,8 @@ public function testReorderArchived() {
$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);
Expand Down

0 comments on commit 6eb8c11

Please sign in to comment.