1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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']);
}
}
|