diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/units/Action/CommentCreationMoveTaskColumnTest.php | 1 | ||||
-rw-r--r-- | tests/units/Action/CommentCreationTest.php | 1 | ||||
-rw-r--r-- | tests/units/Action/TaskAssignCategoryLinkTest.php | 1 | ||||
-rw-r--r-- | tests/units/Action/TaskAssignUserTest.php | 1 | ||||
-rw-r--r-- | tests/units/Core/Ldap/LdapGroupTest.php | 1 | ||||
-rw-r--r-- | tests/units/Formatter/TaskFilterCalendarFormatterTest.php | 8 | ||||
-rw-r--r-- | tests/units/Formatter/TaskFilterICalendarFormatterTest.php | 3 | ||||
-rw-r--r-- | tests/units/Model/CategoryTest.php | 220 | ||||
-rw-r--r-- | tests/units/Model/ColorTest.php | 93 | ||||
-rw-r--r-- | tests/units/Model/ProjectDailyStatsTest.php | 9 | ||||
-rw-r--r-- | tests/units/Model/TaskDuplicationTest.php | 20 | ||||
-rw-r--r-- | tests/units/Notification/WebhookTest.php | 3 | ||||
-rw-r--r-- | tests/units/Validator/PasswordResetValidatorTest.php | 1 |
13 files changed, 297 insertions, 65 deletions
diff --git a/tests/units/Action/CommentCreationMoveTaskColumnTest.php b/tests/units/Action/CommentCreationMoveTaskColumnTest.php index 87ee86ea..6464639e 100644 --- a/tests/units/Action/CommentCreationMoveTaskColumnTest.php +++ b/tests/units/Action/CommentCreationMoveTaskColumnTest.php @@ -7,7 +7,6 @@ use Kanboard\Model\Task; use Kanboard\Model\TaskCreation; use Kanboard\Model\Comment; use Kanboard\Model\Project; -use Kanboard\Model\ProjectUserRole; use Kanboard\Action\CommentCreationMoveTaskColumn; class CommentCreationMoveTaskColumnTest extends Base diff --git a/tests/units/Action/CommentCreationTest.php b/tests/units/Action/CommentCreationTest.php index 8460a350..042a8f8b 100644 --- a/tests/units/Action/CommentCreationTest.php +++ b/tests/units/Action/CommentCreationTest.php @@ -3,7 +3,6 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Event\GenericEvent; -use Kanboard\Model\Task; use Kanboard\Model\TaskCreation; use Kanboard\Model\Comment; use Kanboard\Model\Project; diff --git a/tests/units/Action/TaskAssignCategoryLinkTest.php b/tests/units/Action/TaskAssignCategoryLinkTest.php index f638e017..da83d541 100644 --- a/tests/units/Action/TaskAssignCategoryLinkTest.php +++ b/tests/units/Action/TaskAssignCategoryLinkTest.php @@ -2,7 +2,6 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\Task; use Kanboard\Model\TaskCreation; use Kanboard\Model\TaskFinder; use Kanboard\Model\Project; diff --git a/tests/units/Action/TaskAssignUserTest.php b/tests/units/Action/TaskAssignUserTest.php index d1cb72b9..31404c0b 100644 --- a/tests/units/Action/TaskAssignUserTest.php +++ b/tests/units/Action/TaskAssignUserTest.php @@ -8,7 +8,6 @@ use Kanboard\Model\TaskFinder; use Kanboard\Model\Project; use Kanboard\Model\ProjectUserRole; use Kanboard\Model\User; -use Kanboard\Model\Task; use Kanboard\Action\TaskAssignUser; use Kanboard\Core\Security\Role; diff --git a/tests/units/Core/Ldap/LdapGroupTest.php b/tests/units/Core/Ldap/LdapGroupTest.php index 3f538249..4341ffc8 100644 --- a/tests/units/Core/Ldap/LdapGroupTest.php +++ b/tests/units/Core/Ldap/LdapGroupTest.php @@ -4,7 +4,6 @@ require_once __DIR__.'/../../Base.php'; use Kanboard\Core\Ldap\Group; use Kanboard\Core\Ldap\Entries; -use Kanboard\Core\Security\Role; class LdapGroupTest extends Base { diff --git a/tests/units/Formatter/TaskFilterCalendarFormatterTest.php b/tests/units/Formatter/TaskFilterCalendarFormatterTest.php index a42e865f..09dd0de6 100644 --- a/tests/units/Formatter/TaskFilterCalendarFormatterTest.php +++ b/tests/units/Formatter/TaskFilterCalendarFormatterTest.php @@ -3,14 +3,6 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Formatter\TaskFilterCalendarFormatter; -use Kanboard\Model\Project; -use Kanboard\Model\User; -use Kanboard\Model\TaskCreation; -use Kanboard\Core\DateParser; -use Kanboard\Model\Category; -use Kanboard\Model\Subtask; -use Kanboard\Model\Config; -use Kanboard\Model\Swimlane; class TaskFilterCalendarFormatterTest extends Base { diff --git a/tests/units/Formatter/TaskFilterICalendarFormatterTest.php b/tests/units/Formatter/TaskFilterICalendarFormatterTest.php index 915cdda2..6de9cf0f 100644 --- a/tests/units/Formatter/TaskFilterICalendarFormatterTest.php +++ b/tests/units/Formatter/TaskFilterICalendarFormatterTest.php @@ -8,10 +8,7 @@ use Kanboard\Model\Project; use Kanboard\Model\User; use Kanboard\Model\TaskCreation; use Kanboard\Core\DateParser; -use Kanboard\Model\Category; -use Kanboard\Model\Subtask; use Kanboard\Model\Config; -use Kanboard\Model\Swimlane; class TaskFilterICalendarFormatterTest extends Base { diff --git a/tests/units/Model/CategoryTest.php b/tests/units/Model/CategoryTest.php index 3a64e26c..600007d0 100644 --- a/tests/units/Model/CategoryTest.php +++ b/tests/units/Model/CategoryTest.php @@ -2,6 +2,7 @@ require_once __DIR__.'/../Base.php'; +use Kanboard\Model\Config; use Kanboard\Model\TaskCreation; use Kanboard\Model\TaskFinder; use Kanboard\Model\Project; @@ -11,55 +12,206 @@ class CategoryTest extends Base { public function testCreation() { - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); - $c = new Category($this->container); - - $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); - $this->assertEquals(1, $c->create(array('name' => 'Category #1', 'project_id' => 1))); - $this->assertEquals(2, $c->create(array('name' => 'Category #2', 'project_id' => 1))); - $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'category_id' => 2))); - - $task = $tf->getById(1); - $this->assertTrue(is_array($task)); + $taskCreationModel = new TaskCreation($this->container); + $taskFinderModel = new TaskFinder($this->container); + $projectModel = new Project($this->container); + $categoryModel = new Category($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); + $this->assertEquals(1, $categoryModel->create(array('name' => 'Category #1', 'project_id' => 1))); + $this->assertEquals(2, $categoryModel->create(array('name' => 'Category #2', 'project_id' => 1))); + $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1, 'category_id' => 2))); + + $task = $taskFinderModel->getById(1); $this->assertEquals(2, $task['category_id']); - $category = $c->getById(2); - $this->assertTrue(is_array($category)); + $category = $categoryModel->getById(2); $this->assertEquals(2, $category['id']); $this->assertEquals('Category #2', $category['name']); $this->assertEquals(1, $category['project_id']); + } + + public function testExists() + { + $projectModel = new Project($this->container); + $categoryModel = new Category($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); + $this->assertEquals(1, $categoryModel->create(array('name' => 'Category #1', 'project_id' => 1))); + $this->assertTrue($categoryModel->exists(1)); + $this->assertFalse($categoryModel->exists(2)); + } + + public function testGetById() + { + $projectModel = new Project($this->container); + $categoryModel = new Category($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); + $this->assertEquals(1, $categoryModel->create(array('name' => 'Category #1', 'project_id' => 1, 'description' => 'test'))); + + $category = $categoryModel->getById(1); + $this->assertEquals(1, $category['id']); + $this->assertEquals('Category #1', $category['name']); + $this->assertEquals(1, $category['project_id']); + $this->assertEquals('test', $category['description']); + } + + public function testGetNameById() + { + $projectModel = new Project($this->container); + $categoryModel = new Category($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); + $this->assertEquals(1, $categoryModel->create(array('name' => 'Category #1', 'project_id' => 1, 'description' => 'test'))); + + $this->assertEquals('Category #1', $categoryModel->getNameById(1)); + $this->assertEquals('', $categoryModel->getNameById(2)); + } + + public function testGetIdByName() + { + $projectModel = new Project($this->container); + $categoryModel = new Category($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); + $this->assertEquals(1, $categoryModel->create(array('name' => 'Category #1', 'project_id' => 1, 'description' => 'test'))); + + $this->assertSame(1, $categoryModel->getIdByName(1, 'Category #1')); + $this->assertSame(0, $categoryModel->getIdByName(1, 'Category #2')); + } + + public function testGetList() + { + $projectModel = new Project($this->container); + $categoryModel = new Category($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); + $this->assertEquals(1, $categoryModel->create(array('name' => 'Category #1', 'project_id' => 1, 'description' => 'test'))); + $this->assertEquals(2, $categoryModel->create(array('name' => 'Category #2', 'project_id' => 1))); + + $categories = $categoryModel->getList(1, false, false); + $this->assertCount(2, $categories); + $this->assertEquals('Category #1', $categories[1]); + $this->assertEquals('Category #2', $categories[2]); + + $categories = $categoryModel->getList(1, true, false); + $this->assertCount(3, $categories); + $this->assertEquals('No category', $categories[0]); + $this->assertEquals('Category #1', $categories[1]); + $this->assertEquals('Category #2', $categories[2]); - $this->assertEquals(2, $c->getIdByName(1, 'Category #2')); - $this->assertEquals(0, $c->getIdByName(2, 'Category #2')); + $categories = $categoryModel->getList(1, false, true); + $this->assertCount(3, $categories); + $this->assertEquals('All categories', $categories[-1]); + $this->assertEquals('Category #1', $categories[1]); + $this->assertEquals('Category #2', $categories[2]); - $this->assertEquals('Category #2', $c->getNameById(2)); - $this->assertEquals('', $c->getNameById(23)); + $categories = $categoryModel->getList(1, true, true); + $this->assertCount(4, $categories); + $this->assertEquals('All categories', $categories[-1]); + $this->assertEquals('No category', $categories[0]); + $this->assertEquals('Category #1', $categories[1]); + $this->assertEquals('Category #2', $categories[2]); + } + + public function testGetAll() + { + $projectModel = new Project($this->container); + $categoryModel = new Category($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); + $this->assertEquals(1, $categoryModel->create(array('name' => 'Category #1', 'project_id' => 1, 'description' => 'test'))); + $this->assertEquals(2, $categoryModel->create(array('name' => 'Category #2', 'project_id' => 1))); + + $categories = $categoryModel->getAll(1); + $this->assertCount(2, $categories); + + $this->assertEquals('Category #1', $categories[0]['name']); + $this->assertEquals('test', $categories[0]['description']); + $this->assertEquals(1, $categories[0]['project_id']); + $this->assertEquals(1, $categories[0]['id']); + + $this->assertEquals('Category #2', $categories[1]['name']); + $this->assertEquals('', $categories[1]['description']); + $this->assertEquals(1, $categories[1]['project_id']); + $this->assertEquals(2, $categories[1]['id']); + } + + public function testCreateDefaultCategories() + { + $projectModel = new Project($this->container); + $categoryModel = new Category($this->container); + $configModel = new Config($this->container); + + $this->assertTrue($configModel->save(array('project_categories' => 'C1, C2, C3'))); + $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); + $this->assertTrue($categoryModel->createDefaultCategories(1)); + + $categories = $categoryModel->getAll(1); + $this->assertCount(3, $categories); + $this->assertEquals('C1', $categories[0]['name']); + $this->assertEquals('C2', $categories[1]['name']); + $this->assertEquals('C3', $categories[2]['name']); + } + + public function testUpdate() + { + $projectModel = new Project($this->container); + $categoryModel = new Category($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); + $this->assertEquals(1, $categoryModel->create(array('name' => 'Category #1', 'project_id' => 1))); + $this->assertTrue($categoryModel->update(array('id' => 1, 'description' => 'test'))); + + $category = $categoryModel->getById(1); + $this->assertEquals('Category #1', $category['name']); + $this->assertEquals(1, $category['project_id']); + $this->assertEquals('test', $category['description']); } public function testRemove() { - $tc = new TaskCreation($this->container); - $tf = new TaskFinder($this->container); - $p = new Project($this->container); - $c = new Category($this->container); - - $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); - $this->assertEquals(1, $c->create(array('name' => 'Category #1', 'project_id' => 1))); - $this->assertEquals(2, $c->create(array('name' => 'Category #2', 'project_id' => 1))); - $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'category_id' => 2))); - - $task = $tf->getById(1); - $this->assertTrue(is_array($task)); + $taskCreationModel = new TaskCreation($this->container); + $taskFinderModel = new TaskFinder($this->container); + $projectModel = new Project($this->container); + $categoryModel = new Category($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); + $this->assertEquals(1, $categoryModel->create(array('name' => 'Category #1', 'project_id' => 1))); + $this->assertEquals(2, $categoryModel->create(array('name' => 'Category #2', 'project_id' => 1))); + $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1, 'category_id' => 2))); + + $task = $taskFinderModel->getById(1); $this->assertEquals(2, $task['category_id']); - $this->assertTrue($c->remove(1)); - $this->assertTrue($c->remove(2)); + $this->assertTrue($categoryModel->remove(1)); + $this->assertTrue($categoryModel->remove(2)); // Make sure tasks assigned with that category are reseted - $task = $tf->getById(1); - $this->assertTrue(is_array($task)); + $task = $taskFinderModel->getById(1); $this->assertEquals(0, $task['category_id']); } + + public function testDuplicate() + { + $projectModel = new Project($this->container); + $categoryModel = new Category($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); + $this->assertEquals(2, $projectModel->create(array('name' => 'Project #2'))); + $this->assertEquals(1, $categoryModel->create(array('name' => 'Category #1', 'project_id' => 1, 'description' => 'test'))); + + $this->assertTrue($categoryModel->duplicate(1, 2)); + + $category = $categoryModel->getById(1); + $this->assertEquals('Category #1', $category['name']); + $this->assertEquals(1, $category['project_id']); + $this->assertEquals('test', $category['description']); + + $category = $categoryModel->getById(2); + $this->assertEquals('Category #1', $category['name']); + $this->assertEquals(2, $category['project_id']); + $this->assertEquals('test', $category['description']); + } } diff --git a/tests/units/Model/ColorTest.php b/tests/units/Model/ColorTest.php new file mode 100644 index 00000000..e96ecb6b --- /dev/null +++ b/tests/units/Model/ColorTest.php @@ -0,0 +1,93 @@ +<?php + +require_once __DIR__.'/../Base.php'; + +use Kanboard\Model\Color; +use Kanboard\Model\Config; + +class ColorTest extends Base +{ + public function testFind() + { + $colorModel = new Color($this->container); + $this->assertEquals('yellow', $colorModel->find('yellow')); + $this->assertEquals('yellow', $colorModel->find('Yellow')); + $this->assertEquals('dark_grey', $colorModel->find('Dark Grey')); + $this->assertEquals('dark_grey', $colorModel->find('dark_grey')); + } + + public function testGetColorProperties() + { + $colorModel = new Color($this->container); + $expected = array( + 'name' => 'Light Green', + 'background' => '#dcedc8', + 'border' => '#689f38', + ); + + $this->assertEquals($expected, $colorModel->getColorProperties('light_green')); + + $expected = array( + 'name' => 'Yellow', + 'background' => 'rgb(245, 247, 196)', + 'border' => 'rgb(223, 227, 45)', + ); + + $this->assertEquals($expected, $colorModel->getColorProperties('foobar')); + } + + public function testGetList() + { + $colorModel = new Color($this->container); + + $colors = $colorModel->getList(); + $this->assertCount(16, $colors); + $this->assertEquals('Yellow', $colors['yellow']); + + $colors = $colorModel->getList(true); + $this->assertCount(17, $colors); + $this->assertEquals('All colors', $colors['']); + $this->assertEquals('Yellow', $colors['yellow']); + } + + public function testGetDefaultColor() + { + $colorModel = new Color($this->container); + $configModel = new Config($this->container); + + $this->assertEquals('yellow', $colorModel->getDefaultColor()); + + $this->container['memoryCache']->flush(); + $this->assertTrue($configModel->save(array('default_color' => 'red'))); + $this->assertEquals('red', $colorModel->getDefaultColor()); + } + + public function testGetDefaultColors() + { + $colorModel = new Color($this->container); + + $colors = $colorModel->getDefaultColors(); + $this->assertCount(16, $colors); + } + + public function testGetBorderColor() + { + $colorModel = new Color($this->container); + $this->assertEquals('rgb(74, 227, 113)', $colorModel->getBorderColor('green')); + } + + public function testGetBackgroundColor() + { + $colorModel = new Color($this->container); + $this->assertEquals('rgb(189, 244, 203)', $colorModel->getBackgroundColor('green')); + } + + public function testGetCss() + { + $colorModel = new Color($this->container); + $css = $colorModel->getCss(); + + $this->assertStringStartsWith('div.color-yellow {', $css); + $this->assertStringEndsWith('td.color-amber { background-color: #ffe082}', $css); + } +} diff --git a/tests/units/Model/ProjectDailyStatsTest.php b/tests/units/Model/ProjectDailyStatsTest.php index 573878c2..c3b20cb9 100644 --- a/tests/units/Model/ProjectDailyStatsTest.php +++ b/tests/units/Model/ProjectDailyStatsTest.php @@ -42,6 +42,13 @@ class ProjectDailyStatsTest extends Base ) ); - $this->assertEquals($expected, $metrics); + $this->assertEquals($expected[0]['day'], $metrics[0]['day']); + $this->assertEquals($expected[1]['day'], $metrics[1]['day']); + + $this->assertEquals($expected[0]['avg_lead_time'], $metrics[0]['avg_lead_time'], '', 2); + $this->assertEquals($expected[1]['avg_lead_time'], $metrics[1]['avg_lead_time'], '', 2); + + $this->assertEquals($expected[0]['avg_cycle_time'], $metrics[0]['avg_cycle_time'], '', 2); + $this->assertEquals($expected[1]['avg_cycle_time'], $metrics[1]['avg_cycle_time'], '', 2); } } diff --git a/tests/units/Model/TaskDuplicationTest.php b/tests/units/Model/TaskDuplicationTest.php index 5ceb357e..c4b36e45 100644 --- a/tests/units/Model/TaskDuplicationTest.php +++ b/tests/units/Model/TaskDuplicationTest.php @@ -57,8 +57,8 @@ class TaskDuplicationTest extends Base // Some categories $this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 1))); $this->assertNotFalse($c->create(array('name' => 'Category #2', 'project_id' => 1))); - $this->assertTrue($c->exists(1, 1)); - $this->assertTrue($c->exists(2, 1)); + $this->assertTrue($c->exists(1)); + $this->assertTrue($c->exists(2)); $this->assertEquals( 1, @@ -110,7 +110,7 @@ class TaskDuplicationTest extends Base $this->assertEquals(2, $p->create(array('name' => 'test2'))); $this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 1))); - $this->assertTrue($c->exists(1, 1)); + $this->assertTrue($c->exists(1)); // We create a task $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1, 'category_id' => 1))); @@ -151,8 +151,8 @@ class TaskDuplicationTest extends Base $this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 1))); $this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 2))); - $this->assertTrue($c->exists(1, 1)); - $this->assertTrue($c->exists(2, 2)); + $this->assertTrue($c->exists(1)); + $this->assertTrue($c->exists(2)); // We create a task $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'category_id' => 1))); @@ -187,9 +187,9 @@ class TaskDuplicationTest extends Base $this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 1))); $this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 2))); $this->assertNotFalse($c->create(array('name' => 'Category #2', 'project_id' => 2))); - $this->assertTrue($c->exists(1, 1)); - $this->assertTrue($c->exists(2, 2)); - $this->assertTrue($c->exists(3, 2)); + $this->assertTrue($c->exists(1)); + $this->assertTrue($c->exists(2)); + $this->assertTrue($c->exists(3)); // We create a task $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'category_id' => 1))); @@ -468,8 +468,8 @@ class TaskDuplicationTest extends Base $this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 1))); $this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 2))); - $this->assertTrue($c->exists(1, 1)); - $this->assertTrue($c->exists(2, 2)); + $this->assertTrue($c->exists(1)); + $this->assertTrue($c->exists(2)); // We create a task $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'category_id' => 1))); diff --git a/tests/units/Notification/WebhookTest.php b/tests/units/Notification/WebhookTest.php index 7215baeb..5984f303 100644 --- a/tests/units/Notification/WebhookTest.php +++ b/tests/units/Notification/WebhookTest.php @@ -3,11 +3,8 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Model\Config; -use Kanboard\Model\Task; use Kanboard\Model\TaskCreation; -use Kanboard\Model\TaskModification; use Kanboard\Model\Project; -use Kanboard\Model\Comment; use Kanboard\Subscriber\NotificationSubscriber; class WebhookTest extends Base diff --git a/tests/units/Validator/PasswordResetValidatorTest.php b/tests/units/Validator/PasswordResetValidatorTest.php index 4af6c75e..d26ad422 100644 --- a/tests/units/Validator/PasswordResetValidatorTest.php +++ b/tests/units/Validator/PasswordResetValidatorTest.php @@ -2,7 +2,6 @@ require_once __DIR__.'/../Base.php'; -use Kanboard\Model\User; use Kanboard\Validator\PasswordResetValidator; class PasswordResetValidatorTest extends Base |