Move events handling to Symfony\EventDispatcher

This commit is contained in:
Frédéric Guillot
2014-12-27 19:10:38 -05:00
parent cf821e117c
commit 17dc5bdc9e
75 changed files with 1076 additions and 1167 deletions

View File

@@ -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']);
}
}