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(array('project_id' => 1, 'name' => 'S1'))); $this->assertEquals(2, $s->create(array('project_id' => 1, 'name' => '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']); }
public function testEvents() { $tp = new TaskPosition($this->container); $tc = new TaskCreation($this->container); $tf = new TaskFinder($this->container); $p = new Project($this->container); $s = new Swimlane($this->container); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'test 1'))); $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1))); $this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 2))); $this->container['dispatcher']->addListener(Task::EVENT_MOVE_COLUMN, array($this, 'onMoveColumn')); $this->container['dispatcher']->addListener(Task::EVENT_MOVE_POSITION, array($this, 'onMovePosition')); $this->container['dispatcher']->addListener(Task::EVENT_MOVE_SWIMLANE, array($this, 'onMoveSwimlane')); // We move the task 1 to the column 2 $this->assertTrue($tp->movePosition(1, 1, 2, 1)); $task = $tf->getById(1); $this->assertEquals(1, $task['id']); $this->assertEquals(2, $task['column_id']); $this->assertEquals(1, $task['position']); $task = $tf->getById(2); $this->assertEquals(2, $task['id']); $this->assertEquals(2, $task['column_id']); $this->assertEquals(2, $task['position']); $called = $this->container['dispatcher']->getCalledListeners(); $this->assertArrayHasKey(Task::EVENT_MOVE_COLUMN . '.TaskPositionTest::onMoveColumn', $called); $this->assertEquals(1, count($called)); // We move the task 1 to the position 2 $this->assertTrue($tp->movePosition(1, 1, 2, 2)); $task = $tf->getById(1); $this->assertEquals(1, $task['id']); $this->assertEquals(2, $task['column_id']); $this->assertEquals(2, $task['position']); $task = $tf->getById(2); $this->assertEquals(2, $task['id']); $this->assertEquals(2, $task['column_id']); $this->assertEquals(1, $task['position']); $called = $this->container['dispatcher']->getCalledListeners(); $this->assertArrayHasKey(Task::EVENT_MOVE_POSITION . '.TaskPositionTest::onMovePosition', $called); $this->assertEquals(2, count($called)); // Move to another swimlane $this->assertTrue($tp->movePosition(1, 1, 3, 1, 1)); $task = $tf->getById(1); $this->assertEquals(1, $task['id']); $this->assertEquals(3, $task['column_id']); $this->assertEquals(1, $task['position']); $this->assertEquals(1, $task['swimlane_id']); $task = $tf->getById(2); $this->assertEquals(2, $task['id']); $this->assertEquals(2, $task['column_id']); $this->assertEquals(1, $task['position']); $this->assertEquals(0, $task['swimlane_id']); $called = $this->container['dispatcher']->getCalledListeners(); $this->assertArrayHasKey(Task::EVENT_MOVE_SWIMLANE . '.TaskPositionTest::onMoveSwimlane', $called); $this->assertEquals(3, count($called)); }
public function testSingleAction() { $tp = new TaskPosition($this->container); $tc = new TaskCreation($this->container); $tf = new TaskFinder($this->container); $board = new Board($this->container); $project = new Project($this->container); $action = new Action($this->container); // We create a project $this->assertEquals(1, $project->create(array('name' => 'unit_test'))); // We create a new action $this->assertEquals(1, $action->create(array('project_id' => 1, 'event_name' => Task::EVENT_MOVE_COLUMN, 'action_name' => 'TaskClose', 'params' => array('column_id' => 4)))); // We create a task $this->assertEquals(1, $tc->create(array('title' => 'unit_test', 'project_id' => 1, 'owner_id' => 1, 'color_id' => 'red', 'column_id' => 1))); // We attach events $action->attachEvents(); // Our task should be open $t1 = $tf->getById(1); $this->assertEquals(1, $t1['is_active']); $this->assertEquals(1, $t1['column_id']); // We move our task $tp->movePosition(1, 1, 4, 1); // Our task should be closed $t1 = $tf->getById(1); $this->assertEquals(4, $t1['column_id']); $this->assertEquals(0, $t1['is_active']); }