public function testGetTitle() { $wn = new WebNotification($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 File($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 (Subscriber\NotificationSubscriber::getSubscribedEvents() as $event_name => $values) { $title = $wn->getTitleFromEvent($event_name, array('task' => $task, 'comment' => $comment, 'subtask' => $subtask, 'file' => $file, 'changes' => array())); $this->assertNotEmpty($title); } $this->assertNotEmpty($wn->getTitleFromEvent(Task::EVENT_OVERDUE, array('tasks' => array(array('id' => 1))))); $this->assertNotEmpty($wn->getTitleFromEvent('unkown', array())); }
public function testGetMailContent() { $en = new EmailNotification($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 File($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 (Subscriber\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()))); } }
public function testMoveDown() { $tc = new TaskCreation($this->container); $s = new Subtask($this->container); $p = new Project($this->container); $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1))); $this->assertEquals(1, $s->create(array('title' => 'subtask #1', 'task_id' => 1))); $this->assertEquals(2, $s->create(array('title' => 'subtask #2', 'task_id' => 1))); $this->assertEquals(3, $s->create(array('title' => 'subtask #3', 'task_id' => 1))); // Move down #1 $this->assertTrue($s->moveDown(1, 1)); // Check positions $subtask = $s->getById(1); $this->assertNotEmpty($subtask); $this->assertEquals(2, $subtask['position']); $subtask = $s->getById(2); $this->assertNotEmpty($subtask); $this->assertEquals(1, $subtask['position']); $subtask = $s->getById(3); $this->assertNotEmpty($subtask); $this->assertEquals(3, $subtask['position']); // We can't move down #3 $this->assertFalse($s->moveDown(1, 3)); // Test remove $this->assertTrue($s->remove(1)); $this->assertTrue($s->moveDown(1, 2)); // Check positions $subtask = $s->getById(1); $this->assertEmpty($subtask); $subtask = $s->getById(2); $this->assertNotEmpty($subtask); $this->assertEquals(2, $subtask['position']); $subtask = $s->getById(3); $this->assertNotEmpty($subtask); $this->assertEquals(1, $subtask['position']); }
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)); }