feat(tests): add tests for labelService and cardService functions

Signed-off-by: grnd-alt <salimbelakkaf@outlook.de>
This commit is contained in:
grnd-alt
2024-11-14 10:13:54 +01:00
committed by Julius Knorr
parent 1fe20dcc1d
commit 2e0f0d29b6
2 changed files with 104 additions and 0 deletions

View File

@@ -24,6 +24,7 @@
namespace OCA\Deck\Service;
use OCA\Deck\Db\Board;
use OCA\Deck\Db\ChangeHelper;
use OCA\Deck\Db\Label;
use OCA\Deck\Db\LabelMapper;
@@ -105,6 +106,53 @@ class LabelServiceTest extends TestCase {
$this->assertEquals($b->getColor(), 'ffffff');
}
public function testCloneLabelIfNotExists() {
$label = new Label();
$label->setId(1);
$label->setTitle('title');
$label->setColor('00ff00');
$this->labelMapper->expects($this->once())
->method('find')
->willReturn($label);
$expectedLabel = new Label();
$expectedLabel->setTitle('title');
$expectedLabel->setColor('00ff00');
$expectedLabel->setBoardId(1);
$this->labelMapper->expects($this->once())
->method('insert')
->with($expectedLabel)
->willReturn($label);
$board = new Board();
$board->setLabels([]);
$this->boardService->expects($this->once())
->method('find')
->willReturn($board);
$this->labelService->cloneLabelIfNotExists(1, 1);
}
public function testCloneLabelIfExists() {
$label = new Label();
$label->setId(1);
$label->setTitle('title');
$label->setColor('00ff00');
$this->labelMapper->expects($this->once())
->method('find')
->willReturn($label);
$this->labelMapper->expects($this->never())
->method('insert')
->with($label);
$board = new Board();
$board->setLabels([$label]);
$this->boardService->expects($this->once())
->method('find')
->willReturn($board);
$this->labelService->cloneLabelIfNotExists(1, 1);
}
public function testDelete() {
$label = new Label();
$label->setId(1);