diff options
author | JLGC @monolinux <monolinux@junglacode.org> | 2016-08-15 23:13:16 -0500 |
---|---|---|
committer | JLGC @monolinux <monolinux@junglacode.org> | 2016-08-15 23:13:16 -0500 |
commit | 683c0464093f6a7976236c68653c2a2cc5dae280 (patch) | |
tree | bf176ecd82415cc4952eea071b7d264dd5fd68b4 /tests/units/Core/Action | |
parent | b1e795fc5b45369f7b9b565b1e106d2673361977 (diff) | |
parent | 5f82a942c0011bf91947b2c1d627c0907bda0c92 (diff) |
Merge https://github.com/kanboard/kanboard
Diffstat (limited to 'tests/units/Core/Action')
-rw-r--r-- | tests/units/Core/Action/ActionManagerTest.php | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/tests/units/Core/Action/ActionManagerTest.php b/tests/units/Core/Action/ActionManagerTest.php index e7c2071f..4878c0c9 100644 --- a/tests/units/Core/Action/ActionManagerTest.php +++ b/tests/units/Core/Action/ActionManagerTest.php @@ -96,7 +96,7 @@ class ActionManagerTest extends Base $actions = $actionManager->getAvailableActions(); $actionManager->attachEvents(); - $this->assertEmpty($this->container['dispatcher']->getListeners()); + $this->assertEmpty($this->dispatcher->getListeners()); $this->assertEquals(1, $projectModel->create(array('name' =>'test'))); $this->assertEquals(1, $actionModel->create(array( @@ -107,7 +107,7 @@ class ActionManagerTest extends Base ))); $actionManager->attachEvents(); - $listeners = $this->container['dispatcher']->getListeners(TaskModel::EVENT_CREATE); + $listeners = $this->dispatcher->getListeners(TaskModel::EVENT_CREATE); $this->assertCount(1, $listeners); $this->assertInstanceOf(get_class($actionTaskAssignColorColumn), $listeners[0][0]); @@ -148,7 +148,7 @@ class ActionManagerTest extends Base $actionManager->attachEvents(); - $listeners = $this->container['dispatcher']->getListeners(TaskModel::EVENT_MOVE_COLUMN); + $listeners = $this->dispatcher->getListeners(TaskModel::EVENT_MOVE_COLUMN); $this->assertCount(1, $listeners); $this->assertInstanceOf(get_class($actionTaskAssignColorColumn), $listeners[0][0]); @@ -158,7 +158,6 @@ class ActionManagerTest extends Base public function testThatEachListenerAreDifferentInstance() { $projectModel = new ProjectModel($this->container); - $projectUserRoleModel = new ProjectUserRoleModel($this->container); $actionModel = new ActionModel($this->container); $actionTaskAssignColorColumn = new TaskAssignColorColumn($this->container); $actionManager = new ActionManager($this->container); @@ -183,7 +182,7 @@ class ActionManagerTest extends Base $actionManager->attachEvents(); - $listeners = $this->container['dispatcher']->getListeners(TaskModel::EVENT_MOVE_COLUMN); + $listeners = $this->dispatcher->getListeners(TaskModel::EVENT_MOVE_COLUMN); $this->assertCount(2, $listeners); $this->assertFalse($listeners[0][0] === $listeners[1][0]); @@ -193,4 +192,35 @@ class ActionManagerTest extends Base $this->assertEquals(1, $listeners[1][0]->getParam('column_id')); $this->assertEquals('red', $listeners[1][0]->getParam('color_id')); } + + public function testRemoveEvents() + { + $projectModel = new ProjectModel($this->container); + $actionModel = new ActionModel($this->container); + $actionTaskAssignColorColumn = new TaskAssignColorColumn($this->container); + $actionManager = new ActionManager($this->container); + $actionManager->register($actionTaskAssignColorColumn); + + $actions = $actionManager->getAvailableActions(); + + $this->assertEquals(1, $projectModel->create(array('name' =>'test'))); + $this->assertEquals(1, $actionModel->create(array( + 'project_id' => 1, + 'event_name' => TaskModel::EVENT_CREATE, + 'action_name' => key($actions), + 'params' => array('column_id' => 1, 'color_id' => 'red'), + ))); + + $actionManager->attachEvents(); + $this->dispatcher->addListener(TaskModel::EVENT_CREATE, function () {}); + + $listeners = $this->dispatcher->getListeners(TaskModel::EVENT_CREATE); + $this->assertCount(2, $listeners); + + $actionManager->removeEvents(); + + $listeners = $this->dispatcher->getListeners(TaskModel::EVENT_CREATE); + $this->assertCount(1, $listeners); + $this->assertNotInstanceOf(get_class($actionTaskAssignColorColumn), $listeners[0]); + } } |