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()))); } }
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())); }
public function validateRemove() { $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->assertTrue($c->create(array('task_id' => 1, 'comment' => 'c1', 'user_id' => 1))); $this->assertTrue($c->remove(1)); $this->assertFalse($c->remove(1)); $this->assertFalse($c->remove(1111)); }
public function testCommentCreation() { $c = new Config($this->container); $p = new Project($this->container); $tc = new TaskCreation($this->container); $cm = new Comment($this->container); $this->container['dispatcher']->addSubscriber(new NotificationSubscriber($this->container)); $c->save(array('webhook_url' => 'http://localhost/comment')); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test'))); $this->assertEquals(1, $cm->create(array('task_id' => 1, 'comment' => 'test comment', 'user_id' => 1))); $this->assertStringStartsWith('http://localhost/comment?token=', $this->container['httpClient']->getUrl()); $event = $this->container['httpClient']->getData(); $this->assertNotEmpty($event); $this->assertArrayHasKey('event_name', $event); $this->assertArrayHasKey('event_data', $event); $this->assertEquals('comment.create', $event['event_name']); $this->assertNotEmpty($event['event_data']); $this->assertArrayHasKey('task_id', $event['event_data']['comment']); $this->assertArrayHasKey('user_id', $event['event_data']['comment']); $this->assertArrayHasKey('comment', $event['event_data']['comment']); $this->assertArrayHasKey('id', $event['event_data']['comment']); $this->assertEquals('test comment', $event['event_data']['comment']['comment']); }
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)); }