Пример #1
0
 public function testDuplicateWithCategoryParameterButNotFound()
 {
     $projectModel = new Project($this->container);
     $actionModel = new Action($this->container);
     $categoryModel = new Category($this->container);
     $this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
     $this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
     $this->assertEquals(1, $categoryModel->create(array('name' => 'c1', 'project_id' => 1)));
     $this->assertEquals(1, $actionModel->create(array('project_id' => 1, 'event_name' => Task::EVENT_CREATE_UPDATE, 'action_name' => '\\Kanboard\\Action\\TaskAssignColorCategory', 'params' => array('column_id' => 1, 'category_id' => 1))));
     $this->assertTrue($actionModel->duplicate(1, 2));
     $actions = $actionModel->getAllByProject(2);
     $this->assertCount(0, $actions);
 }
Пример #2
0
 public function testCloneProjectWithActionTaskAssignColorCategory()
 {
     $p = new Project($this->container);
     $a = new Action($this->container);
     $c = new Category($this->container);
     $pd = new ProjectDuplication($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'P1')));
     $this->assertEquals(1, $c->create(array('name' => 'C1', 'project_id' => 1)));
     $this->assertEquals(2, $c->create(array('name' => 'C2', 'project_id' => 1)));
     $this->assertEquals(3, $c->create(array('name' => 'C3', 'project_id' => 1)));
     $this->assertEquals(1, $a->create(array('project_id' => 1, 'event_name' => Task::EVENT_CREATE_UPDATE, 'action_name' => 'TaskAssignColorCategory', 'params' => array('color_id' => 'blue', 'category_id' => 2))));
     $this->assertEquals(2, $pd->duplicate(1));
     $actions = $a->getAllByProject(2);
     $this->assertNotEmpty($actions);
     $this->assertEquals('TaskAssignColorCategory', $actions[0]['action_name']);
     $this->assertNotEmpty($actions[0]['params']);
     $this->assertEquals('blue', $actions[0]['params'][0]['value']);
     $this->assertEquals(5, $actions[0]['params'][1]['value']);
 }
Пример #3
0
 public function testAttachEventsWithLoggedUser()
 {
     $this->container['sessionStorage']->user = array('id' => 1);
     $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);
     $actions = $actionManager->getAvailableActions();
     $this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
     $this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
     $this->assertTrue($projectUserRoleModel->addUser(2, 1, Role::PROJECT_MEMBER));
     $this->assertEquals(1, $actionModel->create(array('project_id' => 1, 'event_name' => Task::EVENT_CREATE, 'action_name' => key($actions), 'params' => array('column_id' => 1, 'color_id' => 'red'))));
     $this->assertEquals(2, $actionModel->create(array('project_id' => 2, '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(1, $listeners);
     $this->assertInstanceOf(get_class($actionTaskAssignColorColumn), $listeners[0][0]);
     $this->assertEquals(2, $listeners[0][0]->getProjectId());
 }
Пример #4
0
 public function testMultipleActions()
 {
     $tp = new TaskPosition($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $b = new Board($this->container);
     $p = new Project($this->container);
     $a = new Action($this->container);
     $g = new GithubWebhook($this->container);
     // We create a project
     $this->assertEquals(1, $p->create(array('name' => 'unit_test')));
     // We create a new action
     $this->assertEquals(1, $a->create(array('project_id' => 1, 'event_name' => GithubWebhook::EVENT_ISSUE_OPENED, 'action_name' => 'TaskCreation', 'params' => array())));
     $this->assertEquals(2, $a->create(array('project_id' => 1, 'event_name' => GithubWebhook::EVENT_ISSUE_LABEL_CHANGE, 'action_name' => 'TaskAssignCategoryLabel', 'params' => array('label' => 'bug', 'category_id' => 1))));
     $this->assertEquals(3, $a->create(array('project_id' => 1, 'event_name' => Task::EVENT_CREATE_UPDATE, 'action_name' => 'TaskAssignColorCategory', 'params' => array('color_id' => 'red', 'category_id' => 1))));
     // We attach events
     $a->attachEvents();
     $g->setProjectId(1);
     // We create a Github issue
     $issue = array('number' => 123, 'title' => 'Bugs everywhere', 'body' => 'There is a bug!', 'html_url' => 'http://localhost/');
     $this->assertTrue($g->handleIssueOpened($issue));
     $task = $tf->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(1, $task['is_active']);
     $this->assertEquals(0, $task['category_id']);
     $this->assertEquals('yellow', $task['color_id']);
     // We assign a label to our issue
     $label = array('name' => 'bug');
     $this->assertTrue($g->handleIssueLabeled($issue, $label));
     $task = $tf->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(1, $task['is_active']);
     $this->assertEquals(1, $task['category_id']);
     $this->assertEquals('red', $task['color_id']);
 }
 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'));
 }