API: Change parameters for updateTask, enforce the use of moveTaskPosition() to move a task
This commit is contained in:
parent
e7ccaaeee4
commit
79de1a0cea
|
|
@ -82,9 +82,9 @@ class Task extends Base
|
|||
return $valid ? $this->taskCreation->create($values) : false;
|
||||
}
|
||||
|
||||
public function updateTask($id, $title = null, $project_id = null, $color_id = null, $column_id = null, $owner_id = null,
|
||||
public function updateTask($id, $title = null, $project_id = null, $color_id = null, $owner_id = null,
|
||||
$creator_id = null, $date_due = null, $description = null, $category_id = null, $score = null,
|
||||
$swimlane_id = null, $recurrence_status = null, $recurrence_trigger = null, $recurrence_factor = null,
|
||||
$recurrence_status = null, $recurrence_trigger = null, $recurrence_factor = null,
|
||||
$recurrence_timeframe = null, $recurrence_basedate = null, $reference = null)
|
||||
{
|
||||
$values = array(
|
||||
|
|
@ -92,14 +92,12 @@ class Task extends Base
|
|||
'title' => $title,
|
||||
'project_id' => $project_id,
|
||||
'color_id' => $color_id,
|
||||
'column_id' => $column_id,
|
||||
'owner_id' => $owner_id,
|
||||
'creator_id' => $creator_id,
|
||||
'date_due' => $date_due,
|
||||
'description' => $description,
|
||||
'category_id' => $category_id,
|
||||
'score' => $score,
|
||||
'swimlane_id' => $swimlane_id,
|
||||
'recurrence_status' => $recurrence_status,
|
||||
'recurrence_trigger' => $recurrence_trigger,
|
||||
'recurrence_factor' => $recurrence_factor,
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ class TaskMovedDateSubscriber extends \Core\Base implements EventSubscriberInter
|
|||
{
|
||||
return array(
|
||||
Task::EVENT_MOVE_COLUMN => array('execute', 0),
|
||||
Task::EVENT_MOVE_SWIMLANE => array('execute', 0),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2189,14 +2189,12 @@ Response example:
|
|||
- **title** (string, optional)
|
||||
- **project_id** (integer, optional)
|
||||
- **color_id** (string, optional)
|
||||
- **column_id** (integer, optional)
|
||||
- **owner_id** (integer, optional)
|
||||
- **creator_id** (integer, optional)
|
||||
- **date_due**: ISO8601 format (string, optional)
|
||||
- **description** Markdown content (string, optional)
|
||||
- **category_id** (integer, optional)
|
||||
- **score** (integer, optional)
|
||||
- **swimlane_id** (integer, optional)
|
||||
- **recurrence_status** (integer, optional)
|
||||
- **recurrence_trigger** (integer, optional)
|
||||
- **recurrence_factor** (integer, optional)
|
||||
|
|
@ -2330,6 +2328,7 @@ Response example:
|
|||
- **task_id** (integer, required)
|
||||
- **column_id** (integer, required)
|
||||
- **position** (integer, required)
|
||||
- **swimlane_id** (integer, optional, default=0)
|
||||
- Result on success: **true**
|
||||
- Result on failure: **false**
|
||||
|
||||
|
|
|
|||
|
|
@ -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'] = '';
|
||||
|
||||
|
|
|
|||
|
|
@ -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']);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue