diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-01-19 21:39:11 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-01-19 21:39:11 -0500 |
commit | 209dae72faee6042695eb480e2424b311a09bdb0 (patch) | |
tree | 61f9e03f616d07a18f07872773d636ac866c1b3f /tests | |
parent | 885c877f4b58058a0d68eaf31fb9d034753787fe (diff) |
Handle notifications for group members attached to a project
Diffstat (limited to 'tests')
-rw-r--r-- | tests/units/Model/UserNotificationTest.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/units/Model/UserNotificationTest.php b/tests/units/Model/UserNotificationTest.php index bf3b1b3f..8168a375 100644 --- a/tests/units/Model/UserNotificationTest.php +++ b/tests/units/Model/UserNotificationTest.php @@ -7,11 +7,14 @@ use Kanboard\Model\TaskCreation; use Kanboard\Model\Subtask; use Kanboard\Model\Comment; use Kanboard\Model\User; +use Kanboard\Model\Group; +use Kanboard\Model\GroupMember; use Kanboard\Model\File; use Kanboard\Model\Project; use Kanboard\Model\ProjectPermission; use Kanboard\Model\Task; use Kanboard\Model\ProjectUserRole; +use Kanboard\Model\ProjectGroupRole; use Kanboard\Model\UserNotification; use Kanboard\Model\UserNotificationFilter; use Kanboard\Model\UserNotificationType; @@ -98,6 +101,42 @@ class UserNotificationTest extends Base $this->assertEquals(array(1), $settings['notification_projects']); } + public function testGetGroupMembersWithNotificationEnabled() + { + $userModel = new User($this->container); + $groupModel = new Group($this->container); + $groupMemberModel = new GroupMember($this->container); + $projectModel = new Project($this->container); + $userNotificationModel = new UserNotification($this->container); + $projectGroupRole = new ProjectGroupRole($this->container); + $projectUserRole = new ProjectUserRole($this->container); + + $this->assertEquals(2, $userModel->create(array('username' => 'user1', 'email' => 'user1@here', 'notifications_enabled' => 1))); + $this->assertEquals(3, $userModel->create(array('username' => 'user2', 'email' => '', 'notifications_enabled' => 1))); + $this->assertEquals(4, $userModel->create(array('username' => 'user3'))); + + $this->assertEquals(1, $groupModel->create('G1')); + $this->assertEquals(2, $groupModel->create('G2')); + + $this->assertTrue($groupMemberModel->addUser(1, 2)); + $this->assertTrue($groupMemberModel->addUser(1, 3)); + $this->assertTrue($groupMemberModel->addUser(1, 4)); + $this->assertTrue($groupMemberModel->addUser(2, 2)); + $this->assertTrue($groupMemberModel->addUser(2, 3)); + + $this->assertEquals(1, $projectModel->create(array('name' => 'P1'))); + + $this->assertTrue($projectGroupRole->addGroup(1, 1, Role::PROJECT_MEMBER)); + $this->assertTrue($projectGroupRole->addGroup(1, 2, Role::PROJECT_VIEWER)); + + $this->assertTrue($projectUserRole->addUser(1, 2, Role::PROJECT_MEMBER)); + + $users = $userNotificationModel->getUsersWithNotificationEnabled(1); + $this->assertCount(2, $users); + $this->assertEquals('user1', $users[0]['username']); + $this->assertEquals('user2', $users[1]['username']); + } + public function testGetProjectMembersWithNotifications() { $u = new User($this->container); |