diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-10-17 09:51:15 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-10-17 09:51:15 -0400 |
commit | 73a5b9bc75d40a30e7c9674b292957657ac01f63 (patch) | |
tree | ff5bb8a90452a2ff1351c192575e5d241a8b4417 /tests | |
parent | 98b203fe691ec1ea9d6d19e916827185b575b05a (diff) |
Make user notifications pluggable
Diffstat (limited to 'tests')
-rw-r--r-- | tests/units/Base.php | 6 | ||||
-rw-r--r-- | tests/units/Model/NotificationTypeTest.php | 26 | ||||
-rw-r--r-- | tests/units/Model/UserNotificationFilterTest.php (renamed from tests/units/Model/NotificationFilterTest.php) | 90 | ||||
-rw-r--r-- | tests/units/Model/UserNotificationTest.php (renamed from tests/units/Model/NotificationTest.php) | 75 | ||||
-rw-r--r-- | tests/units/Model/UserNotificationTypeTest.php | 30 | ||||
-rw-r--r-- | tests/units/Model/UserUnreadNotificationTest.php (renamed from tests/units/Model/WebNotificationTest.php) | 24 | ||||
-rw-r--r-- | tests/units/Notification/MailTest.php (renamed from tests/units/Model/EmailNotificationTest.php) | 14 |
7 files changed, 138 insertions, 127 deletions
diff --git a/tests/units/Base.php b/tests/units/Base.php index 3b7ffa2a..fe054344 100644 --- a/tests/units/Base.php +++ b/tests/units/Base.php @@ -88,6 +88,12 @@ abstract class Base extends PHPUnit_Framework_TestCase $this->container['logger']->setLogger(new File('/dev/null')); $this->container['httpClient'] = new FakeHttpClient; $this->container['emailClient'] = $this->getMockBuilder('EmailClient')->setMethods(array('send'))->getMock(); + + $this->container['userNotificationType'] = $this + ->getMockBuilder('\Kanboard\Model\UserNotificationType') + ->setConstructorArgs(array($this->container)) + ->setMethods(array('getType')) + ->getMock(); } public function tearDown() diff --git a/tests/units/Model/NotificationTypeTest.php b/tests/units/Model/NotificationTypeTest.php deleted file mode 100644 index bf3c78a0..00000000 --- a/tests/units/Model/NotificationTypeTest.php +++ /dev/null @@ -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); - } -} diff --git a/tests/units/Model/NotificationFilterTest.php b/tests/units/Model/UserNotificationFilterTest.php index 2f8cdc8a..0b5f1d98 100644 --- a/tests/units/Model/NotificationFilterTest.php +++ b/tests/units/Model/UserNotificationFilterTest.php @@ -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))); diff --git a/tests/units/Model/NotificationTest.php b/tests/units/Model/UserNotificationTest.php index 251ae1b2..8d7dec60 100644 --- a/tests/units/Model/NotificationTest.php +++ b/tests/units/Model/UserNotificationTest.php @@ -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(); - - $this->container['emailNotification'] - ->expects($this->once()) - ->method('send'); - - $this->container['webNotification'] - ->expects($this->once()) - ->method('send'); + $notifier + ->expects($this->exactly(2)) + ->method('notifyUser'); + + $this->container['userNotificationType'] + ->expects($this->at(0)) + ->method('getType') + ->with($this->equalTo('email')) + ->will($this->returnValue($notifier)); + + $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))); } diff --git a/tests/units/Model/UserNotificationTypeTest.php b/tests/units/Model/UserNotificationTypeTest.php new file mode 100644 index 00000000..a0a1491d --- /dev/null +++ b/tests/units/Model/UserNotificationTypeTest.php @@ -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); + } +} diff --git a/tests/units/Model/WebNotificationTest.php b/tests/units/Model/UserUnreadNotificationTest.php index 8ed37692..130a6eba 100644 --- a/tests/units/Model/WebNotificationTest.php +++ b/tests/units/Model/UserUnreadNotificationTest.php @@ -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)); diff --git a/tests/units/Model/EmailNotificationTest.php b/tests/units/Notification/MailTest.php index 342f0aa9..3aa1a39c 100644 --- a/tests/units/Model/EmailNotificationTest.php +++ b/tests/units/Notification/MailTest.php @@ -11,14 +11,14 @@ use Kanboard\Model\File; use Kanboard\Model\Project; use Kanboard\Model\Task; use Kanboard\Model\ProjectPermission; -use Kanboard\Model\EmailNotification; +use Kanboard\Notification\Mail; use Kanboard\Subscriber\NotificationSubscriber; -class EmailNotificationTest extends Base +class MailTest extends Base { public function testGetMailContent() { - $en = new EmailNotification($this->container); + $en = new Mail($this->container); $p = new Project($this->container); $tf = new TaskFinder($this->container); $tc = new TaskCreation($this->container); @@ -63,7 +63,7 @@ class EmailNotificationTest extends Base public function testSendWithEmailAddress() { - $en = new EmailNotification($this->container); + $en = new Mail($this->container); $p = new Project($this->container); $tf = new TaskFinder($this->container); $tc = new TaskCreation($this->container); @@ -89,12 +89,12 @@ class EmailNotificationTest extends Base $this->stringContains('test') ); - $en->send($u->getById(1), Task::EVENT_CREATE, array('task' => $tf->getDetails(1))); + $en->notifyUser($u->getById(1), Task::EVENT_CREATE, array('task' => $tf->getDetails(1))); } public function testSendWithoutEmailAddress() { - $en = new EmailNotification($this->container); + $en = new Mail($this->container); $p = new Project($this->container); $tf = new TaskFinder($this->container); $tc = new TaskCreation($this->container); @@ -113,6 +113,6 @@ class EmailNotificationTest extends Base ->expects($this->never()) ->method('send'); - $en->send($u->getById(1), Task::EVENT_CREATE, array('task' => $tf->getDetails(1))); + $en->notifyUser($u->getById(1), Task::EVENT_CREATE, array('task' => $tf->getDetails(1))); } } |