summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-01-10 14:00:34 -0500
committerFrederic Guillot <fred@kanboard.net>2016-01-10 14:00:34 -0500
commitff1de5c06d536be7fe2875820d4d0b2849512cb5 (patch)
tree38dfad7c5f3c9aa83edf47b2b22af7b2b50dbd7b /tests
parent26e3996014936268f4acbfa214fa881af9320ddd (diff)
Fix bug: Automatic action listeners were using the same instance
Diffstat (limited to 'tests')
-rw-r--r--tests/units/Core/Action/ActionManagerTest.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/units/Core/Action/ActionManagerTest.php b/tests/units/Core/Action/ActionManagerTest.php
index 492b9e03..aae5bd2d 100644
--- a/tests/units/Core/Action/ActionManagerTest.php
+++ b/tests/units/Core/Action/ActionManagerTest.php
@@ -154,4 +154,43 @@ class ActionManagerTest extends Base
$this->assertEquals(2, $listeners[0][0]->getProjectId());
}
+
+ public function testThatEachListenerAreDifferentInstance()
+ {
+ $projectModel = new Project($this->container);
+ $projectUserRoleModel = new ProjectUserRole($this->container);
+ $actionModel = new Action($this->container);
+ $actionTaskAssignColorColumn = new TaskAssignColorColumn($this->container);
+ $actionManager = new ActionManager($this->container);
+ $actionManager->register($actionTaskAssignColorColumn);
+
+ $this->assertEquals(1, $projectModel->create(array('name' =>'test1')));
+ $actions = $actionManager->getAvailableActions();
+
+ $this->assertEquals(1, $actionModel->create(array(
+ 'project_id' => 1,
+ 'event_name' => Task::EVENT_MOVE_COLUMN,
+ 'action_name' => key($actions),
+ 'params' => array('column_id' => 2, 'color_id' => 'green'),
+ )));
+
+ $this->assertEquals(2, $actionModel->create(array(
+ 'project_id' => 1,
+ 'event_name' => Task::EVENT_MOVE_COLUMN,
+ 'action_name' => key($actions),
+ 'params' => array('column_id' => 1, 'color_id' => 'red'),
+ )));
+
+ $actionManager->attachEvents();
+
+ $listeners = $this->container['dispatcher']->getListeners(Task::EVENT_MOVE_COLUMN);
+ $this->assertCount(2, $listeners);
+ $this->assertFalse($listeners[0][0] === $listeners[1][0]);
+
+ $this->assertEquals(2, $listeners[0][0]->getParam('column_id'));
+ $this->assertEquals('green', $listeners[0][0]->getParam('color_id'));
+
+ $this->assertEquals(1, $listeners[1][0]->getParam('column_id'));
+ $this->assertEquals('red', $listeners[1][0]->getParam('color_id'));
+ }
}