Add tests for entities
This commit is contained in:
61
tests/unit/Db/BoardTest.php
Normal file
61
tests/unit/Db/BoardTest.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace OCA\Deck\Db;
|
||||
|
||||
class BoardTest extends \PHPUnit_Framework_TestCase {
|
||||
private function createBoard() {
|
||||
$board = new Board();
|
||||
$board->setId(1);
|
||||
$board->setTitle("My Board");
|
||||
$board->setOwner("admin");
|
||||
$board->setColor("000000");
|
||||
$board->setArchived(false);
|
||||
// TODO: relation shared labels acl
|
||||
return $board;
|
||||
}
|
||||
public function testJsonSerialize() {
|
||||
$board = $this->createBoard();
|
||||
$this->assertEquals([
|
||||
'id' => 1,
|
||||
'title' => "My Board",
|
||||
'owner' => "admin",
|
||||
'color' => "000000",
|
||||
'labels' => null,
|
||||
'acl' => null
|
||||
], $board->jsonSerialize());
|
||||
}
|
||||
|
||||
public function testSetLabels() {
|
||||
$board = $this->createBoard();
|
||||
$board->setLabels(array("foo", "bar"));
|
||||
$this->assertEquals([
|
||||
'id' => 1,
|
||||
'title' => "My Board",
|
||||
'owner' => "admin",
|
||||
'color' => "000000",
|
||||
'labels' => array("foo", "bar"),
|
||||
'acl' => null
|
||||
], $board->jsonSerialize());
|
||||
}
|
||||
public function testSetAcl() {
|
||||
$acl = new Acl();
|
||||
$acl->setId(1);
|
||||
$board = $this->createBoard();
|
||||
$board->setAcl(array($acl));
|
||||
$result = $board->getAcl()[1];
|
||||
$this->assertEquals($acl, $result);
|
||||
}
|
||||
public function testSetShared() {
|
||||
$board = $this->createBoard();
|
||||
$board->setShared(1);
|
||||
$this->assertEquals([
|
||||
'id' => 1,
|
||||
'title' => "My Board",
|
||||
'owner' => "admin",
|
||||
'color' => "000000",
|
||||
'labels' => null,
|
||||
'acl' => null,
|
||||
'shared' => 1,
|
||||
], $board->jsonSerialize());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user