Make user notifications pluggable

This commit is contained in:
Frederic Guillot
2015-10-17 09:51:15 -04:00
parent 98b203fe69
commit 73a5b9bc75
25 changed files with 407 additions and 258 deletions

View File

@@ -1,118 +0,0 @@
<?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\Project;
use Kanboard\Model\Task;
use Kanboard\Model\ProjectPermission;
use Kanboard\Model\EmailNotification;
use Kanboard\Subscriber\NotificationSubscriber;
class EmailNotificationTest extends Base
{
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 (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 testSendWithEmailAddress()
{
$en = new EmailNotification($this->container);
$p = new Project($this->container);
$tf = new TaskFinder($this->container);
$tc = new TaskCreation($this->container);
$u = new User($this->container);
$this->assertEquals(1, $p->create(array('name' => 'test')));
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1)));
$this->assertTrue($u->update(array('id' => 1, 'email' => 'test@localhost')));
$this->container['emailClient'] = $this
->getMockBuilder('\Kanboard\Core\Mail\Client')
->setConstructorArgs(array($this->container))
->setMethods(array('send'))
->getMock();
$this->container['emailClient']
->expects($this->once())
->method('send')
->with(
$this->equalTo('test@localhost'),
$this->equalTo('admin'),
$this->equalTo('[test][New task] test (#1)'),
$this->stringContains('test')
);
$en->send($u->getById(1), Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));
}
public function testSendWithoutEmailAddress()
{
$en = new EmailNotification($this->container);
$p = new Project($this->container);
$tf = new TaskFinder($this->container);
$tc = new TaskCreation($this->container);
$u = new User($this->container);
$this->assertEquals(1, $p->create(array('name' => 'test')));
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1)));
$this->container['emailClient'] = $this
->getMockBuilder('\Kanboard\Core\Mail\Client')
->setConstructorArgs(array($this->container))
->setMethods(array('send'))
->getMock();
$this->container['emailClient']
->expects($this->never())
->method('send');
$en->send($u->getById(1), Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));
}
}

View File

@@ -1,26 +0,0 @@
<?php
require_once __DIR__.'/../Base.php';
use Kanboard\Model\NotificationType;
class NotificationTypeTest extends Base
{
public function testGetTypes()
{
$nt = new NotificationType($this->container);
$this->assertEquals(array('email' => 'Email', 'web' => 'Web'), $nt->getTypes());
}
public function testGetUserNotificationTypes()
{
$nt = new NotificationType($this->container);
$types = $nt->getUserSelectedTypes(1);
$this->assertEmpty($types);
$this->assertTrue($nt->saveUserSelectedTypes(1, array('email', 'web')));
$types = $nt->getUserSelectedTypes(1);
$this->assertNotEmpty($types);
$this->assertEquals(array('email', 'web'), $types);
}
}

View File

@@ -4,107 +4,107 @@ require_once __DIR__.'/../Base.php';
use Kanboard\Model\User;
use Kanboard\Model\Project;
use Kanboard\Model\NotificationFilter;
use Kanboard\Model\Notification;
use Kanboard\Model\UserNotificationFilter;
use Kanboard\Model\UserNotification;
class NotificationFilterTest extends Base
class UserNotificationFilterTest extends Base
{
public function testGetFilters()
{
$nf = new NotificationFilter($this->container);
$nf = new UserNotificationFilter($this->container);
$filters = $nf->getFilters();
$this->assertArrayHasKey(NotificationFilter::FILTER_NONE, $filters);
$this->assertArrayHasKey(NotificationFilter::FILTER_BOTH, $filters);
$this->assertArrayHasKey(NotificationFilter::FILTER_CREATOR, $filters);
$this->assertArrayHasKey(NotificationFilter::FILTER_ASSIGNEE, $filters);
$this->assertArrayHasKey(UserNotificationFilter::FILTER_NONE, $filters);
$this->assertArrayHasKey(UserNotificationFilter::FILTER_BOTH, $filters);
$this->assertArrayHasKey(UserNotificationFilter::FILTER_CREATOR, $filters);
$this->assertArrayHasKey(UserNotificationFilter::FILTER_ASSIGNEE, $filters);
}
public function testSaveProjectFilter()
{
$nf = new NotificationFilter($this->container);
$nf = new UserNotificationFilter($this->container);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
$this->assertEquals(2, $p->create(array('name' => 'UnitTest2')));
$this->assertEmpty($nf->getUserSelectedProjects(1));
$nf->saveUserSelectedProjects(1, array(1, 2));
$this->assertEquals(array(1, 2), $nf->getUserSelectedProjects(1));
$this->assertEmpty($nf->getSelectedProjects(1));
$nf->saveSelectedProjects(1, array(1, 2));
$this->assertEquals(array(1, 2), $nf->getSelectedProjects(1));
}
public function testSaveUserFilter()
{
$nf = new NotificationFilter($this->container);
$nf = new UserNotificationFilter($this->container);
$this->assertEquals(NotificationFilter::FILTER_BOTH, $nf->getUserSelectedFilter(1));
$nf->saveUserFilter(1, NotificationFilter::FILTER_CREATOR);
$this->assertEquals(NotificationFilter::FILTER_CREATOR, $nf->getUserSelectedFilter(1));
$this->assertEquals(UserNotificationFilter::FILTER_BOTH, $nf->getSelectedFilter(1));
$nf->saveFilter(1, UserNotificationFilter::FILTER_CREATOR);
$this->assertEquals(UserNotificationFilter::FILTER_CREATOR, $nf->getSelectedFilter(1));
}
public function testFilterNone()
{
$u = new User($this->container);
$n = new NotificationFilter($this->container);
$n = new UserNotificationFilter($this->container);
$this->assertEquals(2, $u->create(array('username' => 'user1', 'notifications_filter' => NotificationFilter::FILTER_NONE)));
$this->assertEquals(2, $u->create(array('username' => 'user1', 'notifications_filter' => UserNotificationFilter::FILTER_NONE)));
$this->assertTrue($n->filterNone($u->getById(2), array()));
$this->assertEquals(3, $u->create(array('username' => 'user2', 'notifications_filter' => NotificationFilter::FILTER_BOTH)));
$this->assertEquals(3, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilter::FILTER_BOTH)));
$this->assertFalse($n->filterNone($u->getById(3), array()));
}
public function testFilterCreator()
{
$u = new User($this->container);
$n = new NotificationFilter($this->container);
$n = new UserNotificationFilter($this->container);
$this->assertEquals(2, $u->create(array('username' => 'user1', 'notifications_filter' => NotificationFilter::FILTER_CREATOR)));
$this->assertEquals(2, $u->create(array('username' => 'user1', 'notifications_filter' => UserNotificationFilter::FILTER_CREATOR)));
$this->assertTrue($n->filterCreator($u->getById(2), array('task' => array('creator_id' => 2))));
$this->assertEquals(3, $u->create(array('username' => 'user2', 'notifications_filter' => NotificationFilter::FILTER_CREATOR)));
$this->assertEquals(3, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilter::FILTER_CREATOR)));
$this->assertFalse($n->filterCreator($u->getById(3), array('task' => array('creator_id' => 1))));
$this->assertEquals(4, $u->create(array('username' => 'user3', 'notifications_filter' => NotificationFilter::FILTER_NONE)));
$this->assertEquals(4, $u->create(array('username' => 'user3', 'notifications_filter' => UserNotificationFilter::FILTER_NONE)));
$this->assertFalse($n->filterCreator($u->getById(4), array('task' => array('creator_id' => 2))));
}
public function testFilterAssignee()
{
$u = new User($this->container);
$n = new NotificationFilter($this->container);
$n = new UserNotificationFilter($this->container);
$this->assertEquals(2, $u->create(array('username' => 'user1', 'notifications_filter' => NotificationFilter::FILTER_ASSIGNEE)));
$this->assertEquals(2, $u->create(array('username' => 'user1', 'notifications_filter' => UserNotificationFilter::FILTER_ASSIGNEE)));
$this->assertTrue($n->filterAssignee($u->getById(2), array('task' => array('owner_id' => 2))));
$this->assertEquals(3, $u->create(array('username' => 'user2', 'notifications_filter' => NotificationFilter::FILTER_ASSIGNEE)));
$this->assertEquals(3, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilter::FILTER_ASSIGNEE)));
$this->assertFalse($n->filterAssignee($u->getById(3), array('task' => array('owner_id' => 1))));
$this->assertEquals(4, $u->create(array('username' => 'user3', 'notifications_filter' => NotificationFilter::FILTER_NONE)));
$this->assertEquals(4, $u->create(array('username' => 'user3', 'notifications_filter' => UserNotificationFilter::FILTER_NONE)));
$this->assertFalse($n->filterAssignee($u->getById(4), array('task' => array('owner_id' => 2))));
}
public function testFilterBoth()
{
$u = new User($this->container);
$n = new NotificationFilter($this->container);
$n = new UserNotificationFilter($this->container);
$this->assertEquals(2, $u->create(array('username' => 'user1', 'notifications_filter' => NotificationFilter::FILTER_BOTH)));
$this->assertEquals(2, $u->create(array('username' => 'user1', 'notifications_filter' => UserNotificationFilter::FILTER_BOTH)));
$this->assertTrue($n->filterBoth($u->getById(2), array('task' => array('owner_id' => 2, 'creator_id' => 1))));
$this->assertTrue($n->filterBoth($u->getById(2), array('task' => array('owner_id' => 0, 'creator_id' => 2))));
$this->assertEquals(3, $u->create(array('username' => 'user2', 'notifications_filter' => NotificationFilter::FILTER_BOTH)));
$this->assertEquals(3, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilter::FILTER_BOTH)));
$this->assertFalse($n->filterBoth($u->getById(3), array('task' => array('owner_id' => 1, 'creator_id' => 1))));
$this->assertFalse($n->filterBoth($u->getById(3), array('task' => array('owner_id' => 2, 'creator_id' => 1))));
$this->assertEquals(4, $u->create(array('username' => 'user3', 'notifications_filter' => NotificationFilter::FILTER_NONE)));
$this->assertEquals(4, $u->create(array('username' => 'user3', 'notifications_filter' => UserNotificationFilter::FILTER_NONE)));
$this->assertFalse($n->filterBoth($u->getById(4), array('task' => array('owner_id' => 2, 'creator_id' => 1))));
}
public function testFilterProject()
{
$u = new User($this->container);
$n = new Notification($this->container);
$nf = new NotificationFilter($this->container);
$n = new UserNotification($this->container);
$nf = new UserNotificationFilter($this->container);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
@@ -114,7 +114,7 @@ class NotificationFilterTest extends Base
$this->assertTrue($nf->filterProject($u->getById(1), array()));
// User that select only some projects
$this->assertEquals(2, $u->create(array('username' => 'user2', 'notifications_filter' => NotificationFilter::FILTER_NONE)));
$this->assertEquals(2, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilter::FILTER_NONE)));
$n->saveSettings(2, array('notifications_enabled' => 1, 'notification_projects' => array(2 => true)));
$this->assertFalse($nf->filterProject($u->getById(2), array('task' => array('project_id' => 1))));
@@ -124,10 +124,10 @@ class NotificationFilterTest extends Base
public function testFilterUserWithNoFilter()
{
$u = new User($this->container);
$n = new NotificationFilter($this->container);
$n = new UserNotificationFilter($this->container);
$p = new Project($this->container);
$this->assertEquals(2, $u->create(array('username' => 'user2', 'notifications_filter' => NotificationFilter::FILTER_NONE)));
$this->assertEquals(2, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilter::FILTER_NONE)));
$this->assertTrue($n->shouldReceiveNotification($u->getById(2), array('task' => array('project_id' => 1))));
}
@@ -135,10 +135,10 @@ class NotificationFilterTest extends Base
public function testFilterUserWithAssigneeFilter()
{
$u = new User($this->container);
$n = new NotificationFilter($this->container);
$n = new UserNotificationFilter($this->container);
$p = new Project($this->container);
$this->assertEquals(2, $u->create(array('username' => 'user2', 'notifications_filter' => NotificationFilter::FILTER_ASSIGNEE)));
$this->assertEquals(2, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilter::FILTER_ASSIGNEE)));
$this->assertTrue($n->shouldReceiveNotification($u->getById(2), array('task' => array('project_id' => 1, 'owner_id' => 2))));
$this->assertFalse($n->shouldReceiveNotification($u->getById(2), array('task' => array('project_id' => 1, 'owner_id' => 1))));
@@ -147,10 +147,10 @@ class NotificationFilterTest extends Base
public function testFilterUserWithCreatorFilter()
{
$u = new User($this->container);
$n = new NotificationFilter($this->container);
$n = new UserNotificationFilter($this->container);
$p = new Project($this->container);
$this->assertEquals(2, $u->create(array('username' => 'user2', 'notifications_filter' => NotificationFilter::FILTER_CREATOR)));
$this->assertEquals(2, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilter::FILTER_CREATOR)));
$this->assertTrue($n->shouldReceiveNotification($u->getById(2), array('task' => array('project_id' => 1, 'creator_id' => 2))));
$this->assertFalse($n->shouldReceiveNotification($u->getById(2), array('task' => array('project_id' => 1, 'creator_id' => 1))));
@@ -159,10 +159,10 @@ class NotificationFilterTest extends Base
public function testFilterUserWithBothFilter()
{
$u = new User($this->container);
$n = new NotificationFilter($this->container);
$n = new UserNotificationFilter($this->container);
$p = new Project($this->container);
$this->assertEquals(2, $u->create(array('username' => 'user2', 'notifications_filter' => NotificationFilter::FILTER_BOTH)));
$this->assertEquals(2, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilter::FILTER_BOTH)));
$this->assertTrue($n->shouldReceiveNotification($u->getById(2), array('task' => array('project_id' => 1, 'creator_id' => 2, 'owner_id' => 3))));
$this->assertTrue($n->shouldReceiveNotification($u->getById(2), array('task' => array('project_id' => 1, 'creator_id' => 0, 'owner_id' => 2))));
@@ -173,14 +173,14 @@ class NotificationFilterTest extends Base
public function testFilterUserWithBothFilterAndProjectSelected()
{
$u = new User($this->container);
$n = new Notification($this->container);
$nf = new NotificationFilter($this->container);
$n = new UserNotification($this->container);
$nf = new UserNotificationFilter($this->container);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
$this->assertEquals(2, $p->create(array('name' => 'UnitTest2')));
$this->assertEquals(2, $u->create(array('username' => 'user2', 'notifications_filter' => NotificationFilter::FILTER_BOTH)));
$this->assertEquals(2, $u->create(array('username' => 'user2', 'notifications_filter' => UserNotificationFilter::FILTER_BOTH)));
$n->saveSettings(2, array('notifications_enabled' => 1, 'notification_projects' => array(2 => true)));

View File

@@ -11,18 +11,18 @@ use Kanboard\Model\File;
use Kanboard\Model\Project;
use Kanboard\Model\Task;
use Kanboard\Model\ProjectPermission;
use Kanboard\Model\Notification;
use Kanboard\Model\NotificationFilter;
use Kanboard\Model\NotificationType;
use Kanboard\Subscriber\NotificationSubscriber;
use Kanboard\Model\UserNotification;
use Kanboard\Model\UserNotificationFilter;
use Kanboard\Model\UserNotificationType;
use Kanboard\Subscriber\UserNotificationSubscriber;
class NotificationTest extends Base
class UserNotificationTest extends Base
{
public function testEnableDisableNotification()
{
$u = new User($this->container);
$p = new Project($this->container);
$n = new Notification($this->container);
$n = new UserNotification($this->container);
$pp = new ProjectPermission($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
@@ -38,23 +38,23 @@ class NotificationTest extends Base
public function testReadWriteSettings()
{
$n = new Notification($this->container);
$n = new UserNotification($this->container);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
$n->saveSettings(1, array(
'notifications_enabled' => 1,
'notifications_filter' => NotificationFilter::FILTER_CREATOR,
'notification_types' => array(NotificationType::TYPE_EMAIL => 1),
'notifications_filter' => UserNotificationFilter::FILTER_CREATOR,
'notification_types' => array('email' => 1),
'notification_projects' => array(),
));
$settings = $n->readSettings(1);
$this->assertNotEmpty($settings);
$this->assertEquals(1, $settings['notifications_enabled']);
$this->assertEquals(NotificationFilter::FILTER_CREATOR, $settings['notifications_filter']);
$this->assertEquals(array(NotificationType::TYPE_EMAIL), $settings['notification_types']);
$this->assertEquals(UserNotificationFilter::FILTER_CREATOR, $settings['notifications_filter']);
$this->assertEquals(array('email'), $settings['notification_types']);
$this->assertEmpty($settings['notification_projects']);
$n->saveSettings(1, array(
@@ -67,16 +67,16 @@ class NotificationTest extends Base
$n->saveSettings(1, array(
'notifications_enabled' => 1,
'notifications_filter' => NotificationFilter::FILTER_ASSIGNEE,
'notification_types' => array(NotificationType::TYPE_WEB => 1, NotificationType::TYPE_EMAIL => 1),
'notifications_filter' => UserNotificationFilter::FILTER_ASSIGNEE,
'notification_types' => array('web' => 1, 'email' => 1),
'notification_projects' => array(1 => 1),
));
$settings = $n->readSettings(1);
$this->assertNotEmpty($settings);
$this->assertEquals(1, $settings['notifications_enabled']);
$this->assertEquals(NotificationFilter::FILTER_ASSIGNEE, $settings['notifications_filter']);
$this->assertEquals(array(NotificationType::TYPE_EMAIL, NotificationType::TYPE_WEB), $settings['notification_types']);
$this->assertEquals(UserNotificationFilter::FILTER_ASSIGNEE, $settings['notifications_filter']);
$this->assertEquals(array('email', 'web'), $settings['notification_types']);
$this->assertEquals(array(1), $settings['notification_projects']);
}
@@ -84,7 +84,7 @@ class NotificationTest extends Base
{
$u = new User($this->container);
$p = new Project($this->container);
$n = new Notification($this->container);
$n = new UserNotification($this->container);
$pp = new ProjectPermission($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
@@ -125,7 +125,7 @@ class NotificationTest extends Base
{
$u = new User($this->container);
$p = new Project($this->container);
$n = new Notification($this->container);
$n = new UserNotification($this->container);
$pp = new ProjectPermission($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest1', 'is_everybody_allowed' => 1)));
@@ -155,7 +155,7 @@ class NotificationTest extends Base
public function testSendNotifications()
{
$u = new User($this->container);
$n = new Notification($this->container);
$n = new UserNotification($this->container);
$p = new Project($this->container);
$tc = new TaskCreation($this->container);
$tf = new TaskFinder($this->container);
@@ -168,29 +168,30 @@ class NotificationTest extends Base
$n->saveSettings(1, array(
'notifications_enabled' => 1,
'notifications_filter' => NotificationFilter::FILTER_NONE,
'notification_types' => array(NotificationType::TYPE_WEB => 1, NotificationType::TYPE_EMAIL => 1),
'notifications_filter' => UserNotificationFilter::FILTER_NONE,
'notification_types' => array('web' => 1, 'email' => 1),
));
$this->container['emailNotification'] = $this
->getMockBuilder('\Kanboard\Model\EmailNotification')
->setConstructorArgs(array($this->container))
->setMethods(array('send'))
$notifier = $this
->getMockBuilder('Stdclass')
->setMethods(array('notifyUser'))
->getMock();
$this->container['webNotification'] = $this
->getMockBuilder('\Kanboard\Model\WebNotification')
->setConstructorArgs(array($this->container))
->setMethods(array('send'))
->getMock();
$notifier
->expects($this->exactly(2))
->method('notifyUser');
$this->container['emailNotification']
->expects($this->once())
->method('send');
$this->container['userNotificationType']
->expects($this->at(0))
->method('getType')
->with($this->equalTo('email'))
->will($this->returnValue($notifier));
$this->container['webNotification']
->expects($this->once())
->method('send');
$this->container['userNotificationType']
->expects($this->at(1))
->method('getType')
->with($this->equalTo('web'))
->will($this->returnValue($notifier));
$n->sendNotifications(Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));
}

View File

@@ -0,0 +1,30 @@
<?php
require_once __DIR__.'/../Base.php';
use Kanboard\Model\UserNotificationType;
class UserNotificationTypeTest extends Base
{
public function testGetTypes()
{
$nt = new UserNotificationType($this->container);
$this->assertEmpty($nt->getTypes());
$nt->setType('email', 'Email', 'Something');
$nt->setType('web', 'Web', 'Something');
$this->assertEquals(array('email' => 'Email', 'web' => 'Web'), $nt->getTypes());
}
public function testGetUserNotificationTypes()
{
$nt = new UserNotificationType($this->container);
$types = $nt->getSelectedTypes(1);
$this->assertEmpty($types);
$this->assertTrue($nt->saveSelectedTypes(1, array('email', 'web')));
$types = $nt->getSelectedTypes(1);
$this->assertNotEmpty($types);
$this->assertEquals(array('email', 'web'), $types);
}
}

View File

@@ -10,14 +10,14 @@ use Kanboard\Model\User;
use Kanboard\Model\File;
use Kanboard\Model\Task;
use Kanboard\Model\Project;
use Kanboard\Model\WebNotification;
use Kanboard\Model\UserUnreadNotification;
use Kanboard\Subscriber\NotificationSubscriber;
class WebNotificationTest extends Base
class UserUnreadNotificationTest extends Base
{
public function testGetTitle()
{
$wn = new WebNotification($this->container);
$wn = new UserUnreadNotification($this->container);
$p = new Project($this->container);
$tf = new TaskFinder($this->container);
$tc = new TaskCreation($this->container);
@@ -59,7 +59,7 @@ class WebNotificationTest extends Base
public function testHasNotification()
{
$wn = new WebNotification($this->container);
$wn = new UserUnreadNotification($this->container);
$p = new Project($this->container);
$tf = new TaskFinder($this->container);
$tc = new TaskCreation($this->container);
@@ -70,14 +70,14 @@ class WebNotificationTest extends Base
$this->assertFalse($wn->hasNotifications(1));
$wn->send($u->getById(1), Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));
$wn->create(1, Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));
$this->assertTrue($wn->hasNotifications(1));
}
public function testMarkAllAsRead()
{
$wn = new WebNotification($this->container);
$wn = new UserUnreadNotification($this->container);
$p = new Project($this->container);
$tf = new TaskFinder($this->container);
$tc = new TaskCreation($this->container);
@@ -86,7 +86,7 @@ class WebNotificationTest extends Base
$this->assertEquals(1, $p->create(array('name' => 'test')));
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1)));
$wn->send($u->getById(1), Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));
$wn->create(1, Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));
$this->assertTrue($wn->hasNotifications(1));
$this->assertTrue($wn->markAllAsRead(1));
@@ -97,7 +97,7 @@ class WebNotificationTest extends Base
public function testMarkAsRead()
{
$wn = new WebNotification($this->container);
$wn = new UserUnreadNotification($this->container);
$p = new Project($this->container);
$tf = new TaskFinder($this->container);
$tc = new TaskCreation($this->container);
@@ -106,7 +106,7 @@ class WebNotificationTest extends Base
$this->assertEquals(1, $p->create(array('name' => 'test')));
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1)));
$wn->send($u->getById(1), Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));
$wn->create(1, Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));
$this->assertTrue($wn->hasNotifications(1));
@@ -119,7 +119,7 @@ class WebNotificationTest extends Base
public function testGetAll()
{
$wn = new WebNotification($this->container);
$wn = new UserUnreadNotification($this->container);
$p = new Project($this->container);
$tf = new TaskFinder($this->container);
$tc = new TaskCreation($this->container);
@@ -128,8 +128,8 @@ class WebNotificationTest extends Base
$this->assertEquals(1, $p->create(array('name' => 'test')));
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1)));
$wn->send($u->getById(1), Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));
$wn->send($u->getById(1), Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));
$wn->create(1, Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));
$wn->create(1, Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));
$this->assertEmpty($wn->getAll(2));