Skip to content

Commit 234be86

Browse files
solracsfluka-nextcloud
authored andcommitted
chore: Add tests for label and description clone
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
1 parent 51afd22 commit 234be86

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

tests/unit/Service/CardServiceTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ public function testClone() {
250250
$card->setOrder(0);
251251
$card->setOwner('admin');
252252
$card->setStackId(12345);
253+
$card->setDescription('A test description');
254+
253255
$clonedCard = clone $card;
254256
$clonedCard->setId(2);
255257
$clonedCard->setStackId(1234);
@@ -289,6 +291,10 @@ public function testClone() {
289291
->with(1)
290292
->willReturn([$a1]);
291293

294+
$this->assignedUsersMapper->expects($this->any())
295+
->method('findIn')
296+
->willReturn([]);
297+
292298
// check if labels get cloned
293299
$label = new Label();
294300
$label->setId(1);
@@ -299,6 +305,15 @@ public function testClone() {
299305
->method('assignLabel')
300306
->with($clonedCard->getId(), $label->getId());
301307

308+
$labelForClone = Label::fromRow([
309+
'id' => 1,
310+
'boardId' => 1234,
311+
'cardId' => 2,
312+
]);
313+
$this->labelMapper->expects($this->any())
314+
->method('findAssignedLabelsForCards')
315+
->willReturn([$labelForClone]);
316+
302317
$stackMock = new Stack();
303318
$stackMock->setBoardId(1234);
304319
$this->stackMapper->expects($this->any())
@@ -307,9 +322,15 @@ public function testClone() {
307322

308323
$b = $this->cardService->create('Card title', 123, 'text', 999, 'admin');
309324
$c = $this->cardService->cloneCard($b->getId(), 1234);
325+
310326
$this->assertEquals($b->getTitle(), $c->getTitle());
311327
$this->assertEquals($b->getOwner(), $c->getOwner());
312328
$this->assertNotEquals($b->getStackId(), $c->getStackId());
329+
330+
$this->assertEquals('A test description', $c->getDescription());
331+
332+
$this->assertCount(1, $c->getLabels());
333+
$this->assertEquals($label->getId(), $c->getLabels()[0]->getId());
313334
}
314335

315336
public function testDelete() {

0 commit comments

Comments
 (0)