summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2017-02-08 18:36:13 -0500
committerFrederic Guillot <fred@kanboard.net>2017-02-08 18:36:13 -0500
commit73dce1279760434e1d1b7a903a0a7500462d6f9c (patch)
tree59a4fa8b6aa0215c658d339e6a31a0ba32b10036 /tests
parentd3650eaa2582f6224eb5f5549829b7a84cda1ea4 (diff)
Prevent people to remove columns that contains tasks
Diffstat (limited to 'tests')
-rw-r--r--tests/units/Model/ColumnModelTest.php (renamed from tests/units/Model/ColumnTest.php)33
1 files changed, 32 insertions, 1 deletions
diff --git a/tests/units/Model/ColumnTest.php b/tests/units/Model/ColumnModelTest.php
index 7340a274..75d1da20 100644
--- a/tests/units/Model/ColumnTest.php
+++ b/tests/units/Model/ColumnModelTest.php
@@ -4,8 +4,9 @@ require_once __DIR__.'/../Base.php';
use Kanboard\Model\ProjectModel;
use Kanboard\Model\ColumnModel;
+use Kanboard\Model\TaskCreationModel;
-class ColumnTest extends Base
+class ColumnModelTest extends Base
{
public function testGetColumn()
{
@@ -94,6 +95,36 @@ class ColumnTest extends Base
$this->assertEquals('Done', $columns[3]['title']);
}
+ public function testGetAllWithTasksCount()
+ {
+ $projectModel = new ProjectModel($this->container);
+ $columnModel = new ColumnModel($this->container);
+ $taskCreationModel = new TaskCreationModel($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest')));
+ $this->assertEquals(1, $taskCreationModel->create(array('title' => 'UnitTest', 'project_id' => 1, 'column_id' => 1)));
+ $this->assertEquals(2, $taskCreationModel->create(array('title' => 'UnitTest', 'project_id' => 1, 'column_id' => 2, 'is_active' => 0)));
+
+ $columns = $columnModel->getAllWithTasksCount(1);
+ $this->assertCount(4, $columns);
+
+ $this->assertEquals(1, $columns[0]['id']);
+ $this->assertEquals(1, $columns[0]['position']);
+ $this->assertEquals(1, $columns[0]['project_id']);
+ $this->assertEquals(0, $columns[0]['task_limit']);
+ $this->assertEquals(0, $columns[0]['hide_in_dashboard']);
+ $this->assertEquals('', $columns[0]['description']);
+ $this->assertEquals('Backlog', $columns[0]['title']);
+ $this->assertEquals(1, $columns[0]['nb_open_tasks']);
+ $this->assertEquals(0, $columns[0]['nb_closed_tasks']);
+
+ $this->assertEquals(2, $columns[1]['id']);
+ $this->assertEquals(2, $columns[1]['position']);
+ $this->assertEquals('Ready', $columns[1]['title']);
+ $this->assertEquals(0, $columns[1]['nb_open_tasks']);
+ $this->assertEquals(1, $columns[1]['nb_closed_tasks']);
+ }
+
public function testGetList()
{
$projectModel = new ProjectModel($this->container);