Ejemplo n.º 1
0
 public function testGetMailContent()
 {
     $en = new Mail($this->container);
     $p = new Project($this->container);
     $tf = new TaskFinder($this->container);
     $tc = new TaskCreation($this->container);
     $s = new Subtask($this->container);
     $c = new Comment($this->container);
     $f = new TaskFile($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'test')));
     $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1)));
     $this->assertEquals(1, $s->create(array('title' => 'test', 'task_id' => 1)));
     $this->assertEquals(1, $c->create(array('comment' => 'test', 'task_id' => 1, 'user_id' => 1)));
     $this->assertEquals(1, $f->create(1, 'test', 'blah', 123));
     $task = $tf->getDetails(1);
     $subtask = $s->getById(1, true);
     $comment = $c->getById(1);
     $file = $c->getById(1);
     $this->assertNotEmpty($task);
     $this->assertNotEmpty($subtask);
     $this->assertNotEmpty($comment);
     $this->assertNotEmpty($file);
     foreach (NotificationSubscriber::getSubscribedEvents() as $event => $values) {
         $this->assertNotEmpty($en->getMailContent($event, array('task' => $task, 'comment' => $comment, 'subtask' => $subtask, 'file' => $file, 'changes' => array())));
         $this->assertNotEmpty($en->getMailSubject($event, array('task' => $task, 'comment' => $comment, 'subtask' => $subtask, 'file' => $file, 'changes' => array())));
     }
 }
Ejemplo n.º 2
0
 public function testGetTitle()
 {
     $wn = new Notification($this->container);
     $p = new Project($this->container);
     $tf = new TaskFinder($this->container);
     $tc = new TaskCreation($this->container);
     $s = new Subtask($this->container);
     $c = new Comment($this->container);
     $f = new TaskFile($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'test')));
     $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1)));
     $this->assertEquals(1, $s->create(array('title' => 'test', 'task_id' => 1)));
     $this->assertEquals(1, $c->create(array('comment' => 'test', 'task_id' => 1, 'user_id' => 1)));
     $this->assertEquals(1, $f->create(1, 'test', 'blah', 123));
     $task = $tf->getDetails(1);
     $subtask = $s->getById(1, true);
     $comment = $c->getById(1);
     $file = $c->getById(1);
     $this->assertNotEmpty($task);
     $this->assertNotEmpty($subtask);
     $this->assertNotEmpty($comment);
     $this->assertNotEmpty($file);
     foreach (NotificationSubscriber::getSubscribedEvents() as $event_name => $values) {
         $title = $wn->getTitleWithoutAuthor($event_name, array('task' => $task, 'comment' => $comment, 'subtask' => $subtask, 'file' => $file, 'changes' => array()));
         $this->assertNotEmpty($title);
         $title = $wn->getTitleWithAuthor('foobar', $event_name, array('task' => $task, 'comment' => $comment, 'subtask' => $subtask, 'file' => $file, 'changes' => array()));
         $this->assertNotEmpty($title);
     }
     $this->assertNotEmpty($wn->getTitleWithoutAuthor(Task::EVENT_OVERDUE, array('tasks' => array(array('id' => 1)))));
     $this->assertNotEmpty($wn->getTitleWithoutAuthor('unkown', array()));
 }
Ejemplo n.º 3
0
 public function testUpdate()
 {
     $c = new Comment($this->container);
     $tc = new TaskCreation($this->container);
     $p = new Project($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'test1')));
     $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1)));
     $this->assertNotFalse($c->create(array('task_id' => 1, 'comment' => 'c1', 'user_id' => 1)));
     $this->assertTrue($c->update(array('id' => 1, 'comment' => 'bla')));
     $comment = $c->getById(1);
     $this->assertNotEmpty($comment);
     $this->assertEquals('bla', $comment['comment']);
 }
 public function testSuccess()
 {
     $this->container['sessionStorage']->user = array('id' => 1);
     $projectModel = new Project($this->container);
     $commentModel = new Comment($this->container);
     $taskCreationModel = new TaskCreation($this->container);
     $this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
     $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));
     $event = new GenericEvent(array('project_id' => 1, 'task_id' => 1, 'column_id' => 2));
     $action = new CommentCreationMoveTaskColumn($this->container);
     $action->setProjectId(1);
     $action->setParam('column_id', 2);
     $this->assertTrue($action->execute($event, Task::EVENT_MOVE_COLUMN));
     $comment = $commentModel->getById(1);
     $this->assertNotEmpty($comment);
     $this->assertEquals(1, $comment['task_id']);
     $this->assertEquals(1, $comment['user_id']);
     $this->assertEquals('Moved to column Ready', $comment['comment']);
 }
Ejemplo n.º 5
0
 public function testWithNoUser()
 {
     $action = new CommentCreation($this->container, 1, GithubWebhook::EVENT_ISSUE_COMMENT);
     // We create a task in the first column
     $tc = new TaskCreation($this->container);
     $p = new Project($this->container);
     $c = new Comment($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'test')));
     $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
     // We create an event to move the task to the 2nd column
     $event = array('project_id' => 1, 'task_id' => 1, 'user_id' => 0, 'comment' => 'youpi');
     // Our event should be executed
     $this->assertTrue($action->execute(new GenericEvent($event)));
     $comment = $c->getById(1);
     $this->assertNotEmpty($comment);
     $this->assertEquals(1, $comment['task_id']);
     $this->assertEquals(0, $comment['user_id']);
     $this->assertEquals('youpi', $comment['comment']);
 }
Ejemplo n.º 6
0
 public function testWithUserNotAssignable()
 {
     $userModel = new User($this->container);
     $projectModel = new Project($this->container);
     $projectUserRoleModel = new ProjectUserRole($this->container);
     $commentModel = new Comment($this->container);
     $taskCreationModel = new TaskCreation($this->container);
     $this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
     $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));
     $this->assertEquals(2, $userModel->create(array('username' => 'user1')));
     $event = new GenericEvent(array('project_id' => 1, 'task_id' => 1, 'comment' => 'test123', 'user_id' => 2));
     $action = new CommentCreation($this->container);
     $action->setProjectId(1);
     $action->addEvent('test.event', 'Test Event');
     $this->assertTrue($action->execute($event, 'test.event'));
     $comment = $commentModel->getById(1);
     $this->assertNotEmpty($comment);
     $this->assertEquals(1, $comment['task_id']);
     $this->assertEquals('test123', $comment['comment']);
     $this->assertEquals('', $comment['reference']);
     $this->assertEquals(0, $comment['user_id']);
 }
Ejemplo n.º 7
0
 public function testRemove()
 {
     $u = new User($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $p = new Project($this->container);
     $s = new Subtask($this->container);
     $c = new Comment($this->container);
     $this->assertNotFalse($u->create(array('username' => 'toto', 'password' => '123456', 'name' => 'Toto')));
     $this->assertEquals(1, $p->create(array('name' => 'Project #1')));
     $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'owner_id' => 2)));
     $this->assertEquals(1, $s->create(array('title' => 'Subtask #1', 'user_id' => 2, 'task_id' => 1)));
     $this->assertEquals(1, $c->create(array('comment' => 'foobar', 'user_id' => 2, 'task_id' => 1)));
     $task = $tf->getById(1);
     $this->assertEquals(1, $task['id']);
     $this->assertEquals(2, $task['owner_id']);
     $this->assertTrue($u->remove(1));
     $this->assertTrue($u->remove(2));
     $this->assertFalse($u->remove(2));
     $this->assertFalse($u->remove(55));
     // Make sure that assigned tasks are unassigned after removing the user
     $task = $tf->getById(1);
     $this->assertEquals(1, $task['id']);
     $this->assertEquals(0, $task['owner_id']);
     // Make sure that assigned subtasks are unassigned after removing the user
     $subtask = $s->getById(1);
     $this->assertEquals(1, $subtask['id']);
     $this->assertEquals(0, $subtask['user_id']);
     // Make sure that comments are not related to the user anymore
     $comment = $c->getById(1);
     $this->assertEquals(1, $comment['id']);
     $this->assertEquals(0, $comment['user_id']);
     // Make sure that private projects are also removed
     $user_id1 = $u->create(array('username' => 'toto1', 'password' => '123456', 'name' => 'Toto'));
     $user_id2 = $u->create(array('username' => 'toto2', 'password' => '123456', 'name' => 'Toto'));
     $this->assertNotFalse($user_id1);
     $this->assertNotFalse($user_id2);
     $this->assertEquals(2, $p->create(array('name' => 'Private project #1', 'is_private' => 1), $user_id1, true));
     $this->assertEquals(3, $p->create(array('name' => 'Private project #2', 'is_private' => 1), $user_id2, true));
     $this->assertTrue($u->remove($user_id1));
     $this->assertNotEmpty($p->getById(1));
     $this->assertNotEmpty($p->getById(3));
     $this->assertEmpty($p->getById(2));
 }