diff --git a/Makefile b/Makefile
index 25892ed0c..0a6d272bb 100644
--- a/Makefile
+++ b/Makefile
@@ -169,9 +169,10 @@ ifeq (, $(shell which phpunit 2> /dev/null))
@echo "No phpunit command available, downloading a copy from the web"
mkdir -p $(build_tools_directory)
curl -sSL https://phar.phpunit.de/phpunit.phar -o $(build_tools_directory)/phpunit.phar
- php $(build_tools_directory)/phpunit.phar -c phpunit.xml
- php $(build_tools_directory)/phpunit.phar -c phpunit.integration.xml
+ php $(build_tools_directory)/phpunit.phar -c phpunit.xml --coverage-clover build/php-unit.clover --coverage-html build/html/
+ php $(build_tools_directory)/phpunit.phar -c phpunit.integration.xml --coverage-clover build/php-unit.clover --coverage-html build/html/
+
else
- phpunit -c phpunit.xml
- phpunit -c phpunit.integration.xml
-endif
\ No newline at end of file
+ phpunit -c phpunit.xml --coverage-clover build/php-unit.clover.xml --coverage-html build/html
+ phpunit -c phpunit.integration.xml --coverage-clover build/php-unit.integration.clover.xml --coverage-html build/html-integration
+endif
diff --git a/db/stack.php b/db/stack.php
index 139d5c112..ee2f5bb9a 100644
--- a/db/stack.php
+++ b/db/stack.php
@@ -25,7 +25,7 @@
namespace OCA\Deck\Db;
use JsonSerializable;
-use OCP\AppFramework\Db\Entity;
+
class Stack extends Entity implements JsonSerializable {
diff --git a/phpunit.xml b/phpunit.xml
index 959875b73..e5fd49c33 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -4,4 +4,9 @@
./tests/unit
-
\ No newline at end of file
+
+
+ ./
+
+
+
diff --git a/tests/unit/Db/AclTest.php b/tests/unit/Db/AclTest.php
new file mode 100644
index 000000000..f050987e0
--- /dev/null
+++ b/tests/unit/Db/AclTest.php
@@ -0,0 +1,88 @@
+
+ *
+ * @author Julius Härtl
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+namespace OCA\Deck\Db;
+
+class AclTest extends \PHPUnit_Framework_TestCase {
+ private function createAclUser() {
+ $acl = new Acl();
+ $acl->setId(1);
+ $acl->setParticipant("admin");
+ $acl->setType("user");
+ $acl->setBoardId(1);
+ $acl->setPermissionWrite(1);
+ $acl->setPermissionInvite(1);
+ $acl->setPermissionManage(1);
+ return $acl;
+ }
+ private function createAclGroup() {
+ $acl = new Acl();
+ $acl->setId(1);
+ $acl->setParticipant("administrators");
+ $acl->setType("group");
+ $acl->setBoardId(1);
+ $acl->setPermissionWrite(1);
+ $acl->setPermissionInvite(1);
+ $acl->setPermissionManage(1);
+ return $acl;
+ }
+ public function testJsonSerialize() {
+ $acl = $this->createAclUser();
+ $this->assertEquals([
+ 'id' => 1,
+ 'participant' => 'admin',
+ 'type' => 'user',
+ 'boardId' => 1,
+ 'permissionWrite' => 1,
+ 'permissionInvite' => 1,
+ 'permissionManage' => 1,
+ 'owner' => 0
+ ], $acl->jsonSerialize());
+ $acl = $this->createAclGroup();
+ $this->assertEquals([
+ 'id' => 1,
+ 'participant' => 'administrators',
+ 'type' => 'group',
+ 'boardId' => 1,
+ 'permissionWrite' => 1,
+ 'permissionInvite' => 1,
+ 'permissionManage' => 1,
+ 'owner' => 0
+ ], $acl->jsonSerialize());
+ }
+ public function testSetOwner() {
+ $acl = $this->createAclUser();
+ $acl->setOwner(1);
+ $this->assertEquals([
+ 'id' => 1,
+ 'participant' => 'admin',
+ 'type' => 'user',
+ 'boardId' => 1,
+ 'permissionWrite' => 1,
+ 'permissionInvite' => 1,
+ 'permissionManage' => 1,
+ 'owner' => 1
+ ], $acl->jsonSerialize());
+ }
+
+}
\ No newline at end of file
diff --git a/tests/unit/Db/BoardTest.php b/tests/unit/Db/BoardTest.php
new file mode 100644
index 000000000..dc814d7c6
--- /dev/null
+++ b/tests/unit/Db/BoardTest.php
@@ -0,0 +1,61 @@
+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());
+ }
+}
\ No newline at end of file
diff --git a/tests/unit/Db/CardTest.php b/tests/unit/Db/CardTest.php
new file mode 100644
index 000000000..b7062d16c
--- /dev/null
+++ b/tests/unit/Db/CardTest.php
@@ -0,0 +1,76 @@
+
+ *
+ * @author Julius Härtl
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+namespace OCA\Deck\Db;
+
+class CardTest extends \PHPUnit_Framework_TestCase {
+ private function createCard() {
+ $card = new Card();
+ $card->setId(1);
+ $card->setTitle("My Card");
+ $card->setDescription("a long description");
+ $card->setStackId(1);
+ $card->setType('text');
+ $card->setLastModified(234);
+ $card->setCreatedAt(123);
+ $card->setOwner("admin");
+ $card->setOrder(12);
+ $card->setArchived(false);
+ // TODO: relation shared labels acl
+ return $card;
+ }
+ public function testJsonSerialize() {
+ $card = $this->createCard();
+ $this->assertEquals([
+ 'id' => 1,
+ 'title' => "My Card",
+ 'description' => "a long description",
+ 'type' => 'text',
+ 'lastModified' => 234,
+ 'createdAt' => 123,
+ 'owner' => 'admin',
+ 'order' => 12,
+ 'stackId' => 1,
+ 'labels' => null,
+ 'archived' => false,
+ ], $card->jsonSerialize());
+ }
+ public function testJsonSerializeLabels() {
+ $card = $this->createCard();
+ $card->setLabels(array());
+ $this->assertEquals([
+ 'id' => 1,
+ 'title' => "My Card",
+ 'description' => "a long description",
+ 'type' => 'text',
+ 'lastModified' => 234,
+ 'createdAt' => 123,
+ 'owner' => 'admin',
+ 'order' => 12,
+ 'stackId' => 1,
+ 'labels' => array(),
+ 'archived' => false,
+ ], $card->jsonSerialize());
+ }
+
+}
\ No newline at end of file
diff --git a/tests/unit/Db/EntityTest.php b/tests/unit/Db/EntityTest.php
new file mode 100644
index 000000000..195068899
--- /dev/null
+++ b/tests/unit/Db/EntityTest.php
@@ -0,0 +1,43 @@
+
+ *
+ * @author Julius Härtl
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+namespace OCA\Deck\Db;
+
+class EntityTest extends \PHPUnit_Framework_TestCase {
+
+ public function testRelation() {
+ $entity = new Entity();
+ $entity->foo = null;
+ $entity->addRelation('foo');
+ $entity->setFoo('test');
+ $this->assertEquals([], $entity->getUpdatedFields());
+ }
+
+ public function testWithoutRelation() {
+ $entity = new Entity();
+ $entity->foo = null;
+ $entity->setFoo('test');
+ $this->assertEquals(['foo'=>true], $entity->getUpdatedFields());
+ }
+
+}
\ No newline at end of file
diff --git a/tests/unit/Db/LabelTest.php b/tests/unit/Db/LabelTest.php
new file mode 100644
index 000000000..0057a1e3c
--- /dev/null
+++ b/tests/unit/Db/LabelTest.php
@@ -0,0 +1,60 @@
+
+ *
+ * @author Julius Härtl
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+namespace OCA\Deck\Db;
+
+class LabelTest extends \PHPUnit_Framework_TestCase {
+ private function createLabel() {
+ $label = new Label();
+ $label->setId(1);
+ $label->setTitle("My Label");
+ $label->setColor("000000");
+ return $label;
+ }
+ public function testJsonSerializeBoard() {
+ $label = $this->createLabel();
+ $label->setBoardId(123);
+ $this->assertEquals([
+ 'id' => 1,
+ 'title' => 'My Label',
+ 'boardId' => 123,
+ 'cardId' => null,
+ 'color' => '000000'
+ ], $label->jsonSerialize());
+
+ }
+ public function testJsonSerializeCard() {
+ $label = $this->createLabel();
+ $label->setCardId(123);
+ $this->assertEquals([
+ 'id' => 1,
+ 'title' => 'My Label',
+ 'boardId' => null,
+ 'cardId' => 123,
+ 'color' => '000000'
+ ], $label->jsonSerialize());
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/tests/unit/Db/StackTest.php b/tests/unit/Db/StackTest.php
new file mode 100644
index 000000000..ed1f292af
--- /dev/null
+++ b/tests/unit/Db/StackTest.php
@@ -0,0 +1,57 @@
+
+ *
+ * @author Julius Härtl
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+namespace OCA\Deck\Db;
+
+class StackTest extends \PHPUnit_Framework_TestCase {
+ private function createStack() {
+ $board = new Stack();
+ $board->setId(1);
+ $board->setTitle("My Stack");
+ $board->setBoardId(1);
+ $board->setOrder(1);
+ return $board;
+ }
+ public function testJsonSerialize() {
+ $board = $this->createStack();
+ $this->assertEquals([
+ 'id' => 1,
+ 'title' => "My Stack",
+ 'order' => 1,
+ 'boardId' => 1,
+ 'cards' => array(),
+ ], $board->jsonSerialize());
+ }
+ public function testJsonSerializeWithCards() {
+ $cards = array("foo", "bar");
+ $board = $this->createStack();
+ $board->setCards($cards);
+ $this->assertEquals([
+ 'id' => 1,
+ 'title' => "My Stack",
+ 'order' => 1,
+ 'boardId' => 1,
+ 'cards' => array("foo", "bar"),
+ ], $board->jsonSerialize());
+ }
+}
\ No newline at end of file
diff --git a/tests/unit/controller/BoardControllerTest.php b/tests/unit/controller/BoardControllerTest.php
new file mode 100644
index 000000000..63656666a
--- /dev/null
+++ b/tests/unit/controller/BoardControllerTest.php
@@ -0,0 +1,57 @@
+
+ *
+ * @author Julius Härtl
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+namespace OCA\Deck\Controller;
+
+use PHPUnit_Framework_TestCase;
+
+class BoardControllerTest extends \PHPUnit_Framework_TestCase {
+
+ private $controller;
+ private $request;
+ private $l10n;
+ private $userId = 'john';
+
+ public function setUp() {
+ $this->l10n = $this->request = $this->getMockBuilder(
+ '\OCP\IL10n')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->request = $this->getMockBuilder(
+ '\OCP\IRequest')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->controller = new PageController(
+ 'deck', $this->request, $this->l10n, $this->userId
+ );
+ }
+
+
+ public function testIndex() {
+ $response = $this->controller->index();
+ $this->assertEquals('main', $response->getTemplateName());
+ }
+
+
+}
\ No newline at end of file