Remove class TaskMovedDateSubscriber
This commit is contained in:
parent
c603cb5949
commit
6a0895ef76
|
|
@ -14,6 +14,7 @@ Improvements:
|
|||
* Move validators to a separate namespace
|
||||
* Improve and write unit tests for reports
|
||||
* Reduce the number of SQL queries for project daily column stats
|
||||
* Remove subscriber to update date_moved field
|
||||
|
||||
Bug fixes:
|
||||
|
||||
|
|
|
|||
|
|
@ -120,10 +120,18 @@ class TaskPosition extends Base
|
|||
*/
|
||||
private function updateTaskPosition($task_id, $swimlane_id, $column_id, $position)
|
||||
{
|
||||
$now = time();
|
||||
|
||||
return $this->db->table(Task::TABLE)
|
||||
->eq('id', $task_id)
|
||||
->eq('is_active', 1)
|
||||
->update(array('position' => $position, 'column_id' => $column_id, 'swimlane_id' => $swimlane_id, 'date_modification' => time()));
|
||||
->update(array(
|
||||
'position' => $position,
|
||||
'column_id' => $column_id,
|
||||
'swimlane_id' => $swimlane_id,
|
||||
'date_modification' => $now,
|
||||
'date_moved' => $now,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ class EventDispatcherProvider implements ServiceProviderInterface
|
|||
$container['dispatcher']->addSubscriber(new ProjectModificationDateSubscriber($container));
|
||||
$container['dispatcher']->addSubscriber(new NotificationSubscriber($container));
|
||||
$container['dispatcher']->addSubscriber(new SubtaskTimeTrackingSubscriber($container));
|
||||
$container['dispatcher']->addSubscriber(new TaskMovedDateSubscriber($container));
|
||||
$container['dispatcher']->addSubscriber(new TransitionSubscriber($container));
|
||||
$container['dispatcher']->addSubscriber(new RecurringTaskSubscriber($container));
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Kanboard\Subscriber;
|
||||
|
||||
use Kanboard\Event\TaskEvent;
|
||||
use Kanboard\Model\Task;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
class TaskMovedDateSubscriber extends \Kanboard\Core\Base implements EventSubscriberInterface
|
||||
{
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
Task::EVENT_MOVE_COLUMN => array('execute', 0),
|
||||
Task::EVENT_MOVE_SWIMLANE => array('execute', 0),
|
||||
);
|
||||
}
|
||||
|
||||
public function execute(TaskEvent $event)
|
||||
{
|
||||
if (isset($event['task_id'])) {
|
||||
$this->container['db']->table(Task::TABLE)->eq('id', $event['task_id'])->update(array('date_moved' => time()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once __DIR__.'/../Base.php';
|
||||
|
||||
use Kanboard\Model\TaskPosition;
|
||||
use Kanboard\Model\TaskCreation;
|
||||
use Kanboard\Model\TaskFinder;
|
||||
use Kanboard\Model\Project;
|
||||
use Kanboard\Model\Swimlane;
|
||||
use Kanboard\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(array('project_id' => 1, 'name' => 'S1')));
|
||||
$this->assertEquals(2, $s->create(array('project_id' => 1, 'name' => '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