diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-06-16 20:04:07 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-06-16 20:04:07 -0400 |
commit | 79de1a0cea67d3f6348fa47825edc6fe84a1c454 (patch) | |
tree | 2c03de0f3aa5fb3bff7b51a75295deb08f02f687 /tests | |
parent | e7ccaaeee4180bbf3a9ac23a5423c28185875bac (diff) |
API: Change parameters for updateTask, enforce the use of moveTaskPosition() to move a task
Diffstat (limited to 'tests')
-rw-r--r-- | tests/functionals/ApiTest.php | 42 | ||||
-rw-r--r-- | tests/units/TaskMovedDateSubscriberTest.php | 77 |
2 files changed, 113 insertions, 6 deletions
diff --git a/tests/functionals/ApiTest.php b/tests/functionals/ApiTest.php index 92c752bb..642288b8 100644 --- a/tests/functionals/ApiTest.php +++ b/tests/functionals/ApiTest.php @@ -348,11 +348,6 @@ class Api extends PHPUnit_Framework_TestCase $this->assertEquals('Swimlane A', $swimlanes[2]['name']); } - public function testRemoveSwimlane() - { - $this->assertTrue($this->client->removeSwimlane(1, 2)); - } - public function testCreateTask() { $task = array( @@ -408,6 +403,42 @@ class Api extends PHPUnit_Framework_TestCase $this->assertEmpty($tasks); } + public function testMoveTaskSwimlane() + { + $task_id = $this->getTaskId(); + + $task = $this->client->getTask($task_id); + $this->assertNotFalse($task); + $this->assertTrue(is_array($task)); + $this->assertEquals(1, $task['position']); + $this->assertEquals(2, $task['column_id']); + $this->assertEquals(0, $task['swimlane_id']); + + $moved_timestamp = $task['date_moved']; + sleep(1); + $this->assertTrue($this->client->moveTaskPosition(1, $task_id, 4, 1, 2)); + + $task = $this->client->getTask($task_id); + $this->assertNotFalse($task); + $this->assertTrue(is_array($task)); + $this->assertEquals(1, $task['position']); + $this->assertEquals(4, $task['column_id']); + $this->assertEquals(2, $task['swimlane_id']); + $this->assertNotEquals($moved_timestamp, $task['date_moved']); + } + + public function testRemoveSwimlane() + { + $this->assertTrue($this->client->removeSwimlane(1, 2)); + + $task = $this->client->getTask($this->getTaskId()); + $this->assertNotFalse($task); + $this->assertTrue(is_array($task)); + $this->assertEquals(1, $task['position']); + $this->assertEquals(4, $task['column_id']); + $this->assertEquals(0, $task['swimlane_id']); + } + public function testUpdateTask() { $task = $this->client->getTask(1); @@ -415,7 +446,6 @@ class Api extends PHPUnit_Framework_TestCase $values = array(); $values['id'] = $task['id']; $values['color_id'] = 'green'; - $values['column_id'] = 1; $values['description'] = 'test'; $values['date_due'] = ''; diff --git a/tests/units/TaskMovedDateSubscriberTest.php b/tests/units/TaskMovedDateSubscriberTest.php new file mode 100644 index 00000000..e0364918 --- /dev/null +++ b/tests/units/TaskMovedDateSubscriberTest.php @@ -0,0 +1,77 @@ +<?php + +require_once __DIR__.'/Base.php'; + +use Model\TaskPosition; +use Model\TaskCreation; +use Model\TaskFinder; +use Model\Project; +use Model\Swimlane; +use Subscriber\TaskMovedDateSubscriber; +use Symfony\Component\EventDispatcher\EventDispatcher; + +class TaskMovedDateSubscriberTest extends Base +{ + public function testMoveTaskAnotherColumn() + { + $tp = new TaskPosition($this->container); + $tc = new TaskCreation($this->container); + $p = new Project($this->container); + $tf = new TaskFinder($this->container); + + $this->container['dispatcher'] = new EventDispatcher; + $this->container['dispatcher']->addSubscriber(new TaskMovedDateSubscriber($this->container)); + + $now = time(); + + $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); + $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1))); + + $task = $tf->getById(1); + $this->assertNotEmpty($task); + $this->assertEquals($now, $task['date_moved'], '', 1); + + sleep(1); + + $this->assertTrue($tp->movePosition(1, 1, 2, 1)); + + $task = $tf->getById(1); + $this->assertNotEmpty($task); + $this->assertNotEquals($now, $task['date_moved']); + } + + public function testMoveTaskAnotherSwimlane() + { + $tp = new TaskPosition($this->container); + $tc = new TaskCreation($this->container); + $p = new Project($this->container); + $tf = new TaskFinder($this->container); + $s = new Swimlane($this->container); + + $this->container['dispatcher'] = new EventDispatcher; + $this->container['dispatcher']->addSubscriber(new TaskMovedDateSubscriber($this->container)); + + $now = time(); + + $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); + $this->assertEquals(1, $s->create(1, 'S1')); + $this->assertEquals(2, $s->create(1, 'S2')); + $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1))); + + $task = $tf->getById(1); + $this->assertNotEmpty($task); + $this->assertEquals($now, $task['date_moved'], '', 1); + $this->assertEquals(1, $task['column_id']); + $this->assertEquals(0, $task['swimlane_id']); + + sleep(1); + + $this->assertTrue($tp->movePosition(1, 1, 2, 1, 2)); + + $task = $tf->getById(1); + $this->assertNotEmpty($task); + $this->assertNotEquals($now, $task['date_moved']); + $this->assertEquals(2, $task['column_id']); + $this->assertEquals(2, $task['swimlane_id']); + } +} |