summaryrefslogtreecommitdiff
path: root/tests/units/TaskStatusTest.php
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-12-27 19:10:38 -0500
committerFrédéric Guillot <fred@kanboard.net>2014-12-27 19:10:38 -0500
commit17dc5bdc9ede52ad618bbf326e67e3b6988170f7 (patch)
tree9cf4d325667f11fa735bca84042fb385e3273329 /tests/units/TaskStatusTest.php
parentcf821e117ce8b937cff7f386a107aaa81ba6bf9b (diff)
Move events handling to Symfony\EventDispatcher
Diffstat (limited to 'tests/units/TaskStatusTest.php')
-rw-r--r--tests/units/TaskStatusTest.php23
1 files changed, 20 insertions, 3 deletions
diff --git a/tests/units/TaskStatusTest.php b/tests/units/TaskStatusTest.php
index f2847bda..b1c3f695 100644
--- a/tests/units/TaskStatusTest.php
+++ b/tests/units/TaskStatusTest.php
@@ -33,6 +33,9 @@ class TaskStatusTest extends Base
// We close the task
+ $this->container['dispatcher']->addListener(Task::EVENT_CLOSE, array($this, 'onTaskClose'));
+ $this->container['dispatcher']->addListener(Task::EVENT_OPEN, array($this, 'onTaskOpen'));
+
$this->assertTrue($ts->close(1));
$this->assertTrue($ts->isClosed(1));
@@ -42,8 +45,6 @@ class TaskStatusTest extends Base
$this->assertEquals(time(), $task['date_completed']);
$this->assertEquals(time(), $task['date_modification']);
- $this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CLOSE));
-
// We open the task again
$this->assertTrue($ts->open(1));
@@ -55,6 +56,22 @@ class TaskStatusTest extends Base
$this->assertEquals(0, $task['date_completed']);
$this->assertEquals(time(), $task['date_modification']);
- $this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_OPEN));
+ $called = $this->container['dispatcher']->getCalledListeners();
+ $this->assertArrayHasKey('task.close.TaskStatusTest::onTaskClose', $called);
+ $this->assertArrayHasKey('task.open.TaskStatusTest::onTaskOpen', $called);
+ }
+
+ public function onTaskOpen($event)
+ {
+ $this->assertInstanceOf('Event\TaskEvent', $event);
+ $this->assertArrayHasKey('task_id', $event);
+ $this->assertNotEmpty($event['task_id']);
+ }
+
+ public function onTaskClose($event)
+ {
+ $this->assertInstanceOf('Event\TaskEvent', $event);
+ $this->assertArrayHasKey('task_id', $event);
+ $this->assertNotEmpty($event['task_id']);
}
}