示例#1
0
 public function testFetchActions()
 {
     $action = new Action($this->registry);
     $board = new Board($this->registry);
     $project = new Project($this->registry);
     $this->assertEquals(1, $project->create(array('name' => 'unit_test')));
     // We should have nothing
     $this->assertEmpty($action->getAll());
     $this->assertEmpty($action->getAllByProject(1));
     // We create a new action
     $this->assertTrue($action->create(array('project_id' => 1, 'event_name' => Task::EVENT_MOVE_COLUMN, 'action_name' => 'TaskClose', 'params' => array('column_id' => 4))));
     // We should have our action
     $this->assertNotEmpty($action->getAll());
     $this->assertEquals($action->getAll(), $action->getAllByProject(1));
     $actions = $action->getAll();
     $this->assertEquals(1, count($actions));
     $this->assertEquals(1, $actions[0]['project_id']);
     $this->assertEquals(Task::EVENT_MOVE_COLUMN, $actions[0]['event_name']);
     $this->assertEquals('TaskClose', $actions[0]['action_name']);
     $this->assertEquals('column_id', $actions[0]['params'][0]['name']);
     $this->assertEquals(4, $actions[0]['params'][0]['value']);
 }
示例#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 testDuplicateMixedResults()
 {
     $p = new Project($this->container);
     $pp = new ProjectPermission($this->container);
     $a = new Action($this->container);
     $u = new User($this->container);
     $c = new Category($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'P1')));
     $this->assertEquals(2, $p->create(array('name' => 'P2')));
     $this->assertEquals(1, $c->create(array('name' => 'C1', 'project_id' => 1)));
     $this->assertEquals(2, $c->create(array('name' => 'C2', 'project_id' => 2)));
     $this->assertEquals(3, $c->create(array('name' => 'C1', 'project_id' => 2)));
     $this->assertEquals(2, $u->create(array('username' => 'unittest1')));
     $this->assertTrue($pp->addMember(1, 2));
     $this->assertEquals(1, $a->create(array('project_id' => 1, 'event_name' => Task::EVENT_CREATE_UPDATE, 'action_name' => 'TaskAssignSpecificUser', 'params' => array('column_id' => 1, 'user_id' => 2))));
     $action = $a->getById(1);
     $this->assertNotEmpty($action);
     $this->assertNotEmpty($action['params']);
     $this->assertEquals(2, $a->create(array('project_id' => 1, 'event_name' => Task::EVENT_CREATE_UPDATE, 'action_name' => 'TaskAssignCategoryColor', 'params' => array('color_id' => 'blue', 'category_id' => 1))));
     $action = $a->getById(2);
     $this->assertNotEmpty($action);
     $this->assertNotEmpty($action['params']);
     $this->assertEquals('category_id', $action['params'][1]['name']);
     $this->assertEquals(1, $action['params'][1]['value']);
     $actions = $a->getAllByProject(1);
     $this->assertNotEmpty($actions);
     $this->assertCount(2, $actions);
     $this->assertTrue($a->duplicate(1, 2));
     $actions = $a->getAllByProject(2);
     $this->assertNotEmpty($actions);
     $this->assertCount(1, $actions);
     $actions = $a->getAll();
     $this->assertNotEmpty($actions);
     $this->assertCount(3, $actions);
     $action = $a->getById($actions[2]['id']);
     $this->assertNotEmpty($action);
     $this->assertNotEmpty($action['params']);
     $this->assertEquals('color_id', $action['params'][0]['name']);
     $this->assertEquals('blue', $action['params'][0]['value']);
     $this->assertEquals('category_id', $action['params'][1]['name']);
     $this->assertEquals(3, $action['params'][1]['value']);
 }