diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-10-17 22:19:49 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-10-17 22:19:49 -0400 |
commit | 09da289c2fb18475f372bee24e885617da484e0b (patch) | |
tree | 95d1869ba3236ccdd9234d7909fc16c495c84d44 /tests/units/Model/NotificationTest.php | |
parent | 9283fb88d80cb355ff98364a9a57b657fc511d98 (diff) |
Move slack, hipchat and jabber integrations to plugins
Diffstat (limited to 'tests/units/Model/NotificationTest.php')
-rw-r--r-- | tests/units/Model/NotificationTest.php | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/units/Model/NotificationTest.php b/tests/units/Model/NotificationTest.php new file mode 100644 index 00000000..7f9977ce --- /dev/null +++ b/tests/units/Model/NotificationTest.php @@ -0,0 +1,69 @@ +<?php + +require_once __DIR__.'/../Base.php'; + +use Kanboard\Model\TaskFinder; +use Kanboard\Model\TaskCreation; +use Kanboard\Model\Subtask; +use Kanboard\Model\Comment; +use Kanboard\Model\User; +use Kanboard\Model\File; +use Kanboard\Model\Task; +use Kanboard\Model\Project; +use Kanboard\Model\Notification; +use Kanboard\Subscriber\NotificationSubscriber; + +class NotificationTest extends Base +{ + 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 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 (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())); + } +} |