예제 #1
0
 public function testDuplicateAnotherProjectWithUser()
 {
     $td = new TaskDuplication($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $p = new Project($this->container);
     $pp = new ProjectPermission($this->container);
     // We create 2 projects
     $this->assertEquals(1, $p->create(array('name' => 'test1')));
     $this->assertEquals(2, $p->create(array('name' => 'test2')));
     // We create a task
     $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 2)));
     // We duplicate our task to the 2nd project
     $this->assertEquals(2, $td->duplicateToProject(1, 2));
     // Check the values of the duplicated task
     $task = $tf->getById(2);
     $this->assertNotEmpty($task);
     $this->assertEquals(0, $task['owner_id']);
     $this->assertEquals(5, $task['column_id']);
     $this->assertEquals(1, $task['position']);
     $this->assertEquals(2, $task['project_id']);
     $this->assertEquals('test', $task['title']);
     // We create a new user for our project
     $user = new User($this->container);
     $this->assertNotFalse($user->create(array('username' => 'unittest#1', 'password' => 'unittest')));
     $this->assertTrue($pp->addMember(1, 2));
     $this->assertTrue($pp->addMember(2, 2));
     $this->assertTrue($pp->isUserAllowed(1, 2));
     $this->assertTrue($pp->isUserAllowed(2, 2));
     // We duplicate our task to the 2nd project
     $this->assertEquals(3, $td->duplicateToProject(1, 2));
     // Check the values of the duplicated task
     $task = $tf->getById(3);
     $this->assertNotEmpty($task);
     $this->assertEquals(2, $task['position']);
     $this->assertEquals(2, $task['owner_id']);
     $this->assertEquals(2, $task['project_id']);
     // We duplicate a task with a not allowed user
     $this->assertEquals(4, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 3)));
     $this->assertEquals(5, $td->duplicateToProject(4, 2));
     $task = $tf->getById(5);
     $this->assertNotEmpty($task);
     $this->assertEquals(3, $task['position']);
     $this->assertEquals(0, $task['owner_id']);
     $this->assertEquals(2, $task['project_id']);
     $this->assertEquals(5, $task['column_id']);
 }
예제 #2
0
 public function testDuplicateAnotherProjectWithPredefinedUser()
 {
     $td = new TaskDuplication($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $p = new Project($this->container);
     $pp = new ProjectPermission($this->container);
     // We create 2 projects
     $this->assertEquals(1, $p->create(array('name' => 'test1')));
     $this->assertEquals(2, $p->create(array('name' => 'test2')));
     // We create a task
     $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 2)));
     // We duplicate our task to the 2nd project
     $this->assertEquals(2, $td->duplicateToProject(1, 2, null, null, null, 1));
     // Check the values of the duplicated task
     $task = $tf->getById(2);
     $this->assertNotEmpty($task);
     $this->assertEquals(1, $task['owner_id']);
 }