public function testMoveAnotherProjectWithForbiddenUser() { $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); $user = new User($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 new user for our project $this->assertNotFalse($user->create(array('username' => 'unittest#1', 'password' => 'unittest'))); $this->assertTrue($pp->allowUser(1, 2)); $this->assertTrue($pp->allowUser(2, 2)); $this->assertTrue($pp->isUserAllowed(1, 2)); $this->assertTrue($pp->isUserAllowed(2, 2)); // We create a task $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 3))); // We move our task to the 2nd project $this->assertTrue($td->moveToProject(1, 2)); // Check the values of the moved task $task = $tf->getById(1); $this->assertNotEmpty($task); $this->assertEquals(1, $task['position']); $this->assertEquals(0, $task['owner_id']); $this->assertEquals(2, $task['project_id']); $this->assertEquals(5, $task['column_id']); }
public function testDuplicateRecurringTask() { $td = new TaskDuplication($this->container); $tc = new TaskCreation($this->container); $tf = new TaskFinder($this->container); $p = new Project($this->container); $c = new Category($this->container); $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'date_due' => 1436561776, 'recurrence_status' => Task::RECURRING_STATUS_PENDING, 'recurrence_trigger' => Task::RECURRING_TRIGGER_CLOSE, 'recurrence_factor' => 2, 'recurrence_timeframe' => Task::RECURRING_TIMEFRAME_DAYS, 'recurrence_basedate' => Task::RECURRING_BASEDATE_TRIGGERDATE))); $this->assertEquals(2, $td->duplicateRecurringTask(1)); $task = $tf->getById(1); $this->assertNotEmpty($task); $this->assertEquals(Task::RECURRING_STATUS_PROCESSED, $task['recurrence_status']); $this->assertEquals(2, $task['recurrence_child']); $this->assertEquals(1436561776, $task['date_due'], '', 2); $task = $tf->getById(2); $this->assertNotEmpty($task); $this->assertEquals(Task::RECURRING_STATUS_PENDING, $task['recurrence_status']); $this->assertEquals(Task::RECURRING_TRIGGER_CLOSE, $task['recurrence_trigger']); $this->assertEquals(Task::RECURRING_TIMEFRAME_DAYS, $task['recurrence_timeframe']); $this->assertEquals(Task::RECURRING_BASEDATE_TRIGGERDATE, $task['recurrence_basedate']); $this->assertEquals(1, $task['recurrence_parent']); $this->assertEquals(2, $task['recurrence_factor']); $this->assertEquals(strtotime('+2 days'), $task['date_due'], '', 2); }
public function testMoveAnotherProjectWithoutSwimlane() { $td = new TaskDuplication($this->container); $tc = new TaskCreation($this->container); $tf = new TaskFinder($this->container); $p = new Project($this->container); $s = new Swimlane($this->container); // We create 2 projects $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(2, $p->create(array('name' => 'test2'))); $this->assertNotFalse($s->create(1, 'Swimlane #1')); $this->assertNotFalse($s->create(2, 'Swimlane #2')); // We create a task $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'swimlane_id' => 1))); // We move our task to the 2nd project $this->assertTrue($td->moveToProject(1, 2)); // Check the values of the moved task $task = $tf->getById(1); $this->assertNotEmpty($task); $this->assertEquals(0, $task['owner_id']); $this->assertEquals(0, $task['category_id']); $this->assertEquals(0, $task['swimlane_id']); $this->assertEquals(5, $task['column_id']); $this->assertEquals(1, $task['position']); $this->assertEquals(2, $task['project_id']); $this->assertEquals('test', $task['title']); }