summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2017-10-27 16:16:11 -0700
committerFrederic Guillot <fred@kanboard.net>2017-10-27 16:16:11 -0700
commitcc6618901bc927558dc159ac0dbec1159231c5f1 (patch)
treef1c14931ab88c0056e538e6d62cd1fa667d94a0d /tests
parent0b9c3b0a5b61a61faf9061e040e072e4b198f6d2 (diff)
Remove feature "Allow everybody to access to this project"
Diffstat (limited to 'tests')
-rw-r--r--tests/units/Model/ProjectPermissionModelTest.php12
-rw-r--r--tests/units/Model/ProjectUserRoleTest.php73
-rw-r--r--tests/units/Model/UserNotificationTest.php58
3 files changed, 12 insertions, 131 deletions
diff --git a/tests/units/Model/ProjectPermissionModelTest.php b/tests/units/Model/ProjectPermissionModelTest.php
index 7f604374..4b5a7476 100644
--- a/tests/units/Model/ProjectPermissionModelTest.php
+++ b/tests/units/Model/ProjectPermissionModelTest.php
@@ -120,18 +120,6 @@ class ProjectPermissionModelTest extends Base
$this->assertEquals('Project 3', $users[0]['project_name']);
}
- public function testEverybodyAllowed()
- {
- $projectModel = new ProjectModel($this->container);
- $projectPermission = new ProjectPermissionModel($this->container);
-
- $this->assertEquals(1, $projectModel->create(array('name' => 'Project 1')));
- $this->assertEquals(2, $projectModel->create(array('name' => 'Project 2', 'is_everybody_allowed' => 1)));
-
- $this->assertFalse($projectPermission->isEverybodyAllowed(1));
- $this->assertTrue($projectPermission->isEverybodyAllowed(2));
- }
-
public function testIsUserAllowed()
{
$userModel = new UserModel($this->container);
diff --git a/tests/units/Model/ProjectUserRoleTest.php b/tests/units/Model/ProjectUserRoleTest.php
index d59b15c9..e45080eb 100644
--- a/tests/units/Model/ProjectUserRoleTest.php
+++ b/tests/units/Model/ProjectUserRoleTest.php
@@ -101,26 +101,6 @@ class ProjectUserRoleTest extends Base
$this->assertEquals('', $userRoleModel->getUserRole(1, 2));
}
- public function testGetRoleWithPublicProject()
- {
- $projectModel = new ProjectModel($this->container);
- $userRoleModel = new ProjectUserRoleModel($this->container);
- $userModel = new UserModel($this->container);
-
- $this->assertEquals(2, $userModel->create(array('username' => 'user1', 'name' => 'User1')));
- $this->assertEquals(3, $userModel->create(array('username' => 'user2', 'name' => 'User2')));
-
- $this->assertEquals(1, $projectModel->create(array('name' => 'Test'), 2, true));
-
- $this->assertEquals(Role::PROJECT_MANAGER, $userRoleModel->getUserRole(1, 2));
- $this->assertEquals(null, $userRoleModel->getUserRole(1, 3));
-
- $this->assertTrue($projectModel->update(array('id' => 1, 'is_everybody_allowed' => 1)));
-
- $this->assertEquals(Role::PROJECT_MANAGER, $userRoleModel->getUserRole(1, 2));
- $this->assertEquals(Role::PROJECT_MEMBER, $userRoleModel->getUserRole(1, 3));
- }
-
public function testGetAssignableUsersWithDisabledUsers()
{
$projectModel = new ProjectModel($this->container);
@@ -247,59 +227,6 @@ class ProjectUserRoleTest extends Base
$this->assertEquals('admin', $users[1]);
}
- public function testGetAssignableUsersWithEverybodyAllowed()
- {
- $projectModel = new ProjectModel($this->container);
- $userModel = new UserModel($this->container);
- $userRoleModel = new ProjectUserRoleModel($this->container);
-
- $this->assertEquals(1, $projectModel->create(array('name' => 'Test', 'is_everybody_allowed' => 1)));
-
- $this->assertEquals(2, $userModel->create(array('username' => 'user1', 'name' => 'User1')));
- $this->assertEquals(3, $userModel->create(array('username' => 'user2', 'name' => 'User2')));
- $this->assertEquals(4, $userModel->create(array('username' => 'user3', 'name' => 'User3')));
- $this->assertEquals(5, $userModel->create(array('username' => 'user4', 'name' => 'User4')));
-
- $users = $userRoleModel->getAssignableUsers(1);
- $this->assertCount(5, $users);
-
- $this->assertEquals('admin', $users[1]);
- $this->assertEquals('User1', $users[2]);
- $this->assertEquals('User2', $users[3]);
- $this->assertEquals('User3', $users[4]);
- $this->assertEquals('User4', $users[5]);
- }
-
- public function testGetAssignableUsersWithDisabledUsersAndEverybodyAllowed()
- {
- $projectModel = new ProjectModel($this->container);
- $projectPermission = new ProjectPermissionModel($this->container);
- $userModel = new UserModel($this->container);
- $userRoleModel = new ProjectUserRoleModel($this->container);
-
- $this->assertEquals(2, $userModel->create(array('username' => 'user1', 'name' => 'User1')));
- $this->assertEquals(3, $userModel->create(array('username' => 'user2', 'name' => 'User2')));
-
- $this->assertEquals(1, $projectModel->create(array('name' => 'Project 1', 'is_everybody_allowed' => 1)));
-
- $this->assertTrue($projectPermission->isEverybodyAllowed(1));
-
- $users = $userRoleModel->getAssignableUsers(1);
- $this->assertCount(3, $users);
-
- $this->assertEquals('admin', $users[1]);
- $this->assertEquals('User1', $users[2]);
- $this->assertEquals('User2', $users[3]);
-
- $this->assertTrue($userModel->disable(2));
-
- $users = $userRoleModel->getAssignableUsers(1);
- $this->assertCount(2, $users);
-
- $this->assertEquals('admin', $users[1]);
- $this->assertEquals('User2', $users[3]);
- }
-
public function testGetProjectsByUser()
{
$userModel = new UserModel($this->container);
diff --git a/tests/units/Model/UserNotificationTest.php b/tests/units/Model/UserNotificationTest.php
index 6ee5c875..e568d204 100644
--- a/tests/units/Model/UserNotificationTest.php
+++ b/tests/units/Model/UserNotificationTest.php
@@ -179,55 +179,21 @@ class UserNotificationTest extends Base
$this->assertEquals('user3@here', $users[2]['email']);
}
- public function testGetUsersWithNotificationsWhenEverybodyAllowed()
- {
- $u = new UserModel($this->container);
- $p = new ProjectModel($this->container);
- $n = new UserNotificationModel($this->container);
- $pp = new ProjectPermissionModel($this->container);
-
- $this->assertEquals(1, $p->create(array('name' => 'UnitTest1', 'is_everybody_allowed' => 1)));
- $this->assertTrue($pp->isEverybodyAllowed(1));
-
- // Email + Notifications enabled
- $this->assertEquals(2, $u->create(array('username' => 'user1', 'email' => 'user1@here', 'notifications_enabled' => 1)));
-
- // No email + Notifications enabled
- $this->assertEquals(3, $u->create(array('username' => 'user2', 'email' => '', 'notifications_enabled' => 1)));
-
- // Email + Notifications enabled
- $this->assertEquals(4, $u->create(array('username' => 'user3', 'email' => 'user3@here', 'notifications_enabled' => 1)));
-
- // User disabled
- $this->assertEquals(5, $u->create(array('username' => 'user4', 'email' => 'user3@here', 'notifications_enabled' => 1, 'is_active' => 0)));
-
- // No email + notifications disabled
- $this->assertEquals(6, $u->create(array('username' => 'user5')));
-
- $users = $n->getUsersWithNotificationEnabled(1);
-
- $this->assertNotEmpty($users);
- $this->assertCount(3, $users);
- $this->assertEquals('user1@here', $users[0]['email']);
- $this->assertEquals('', $users[1]['email']);
- $this->assertEquals('user3@here', $users[2]['email']);
- }
-
public function testSendNotifications()
{
- $u = new UserModel($this->container);
- $n = new UserNotificationModel($this->container);
- $p = new ProjectModel($this->container);
- $tc = new TaskCreationModel($this->container);
- $tf = new TaskFinderModel($this->container);
- $pp = new ProjectPermissionModel($this->container);
+ $userModel = new UserModel($this->container);
+ $userNotificationModel = new UserNotificationModel($this->container);
+ $projectModel = new ProjectModel($this->container);
+ $taskCreationModel = new TaskCreationModel($this->container);
+ $taskFinderModel = new TaskFinderModel($this->container);
+ $projectUserRoleModel = new ProjectUserRoleModel($this->container);
- $this->assertEquals(1, $p->create(array('name' => 'UnitTest1', 'is_everybody_allowed' => 1)));
- $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1)));
- $this->assertTrue($u->update(array('id' => 1, 'email' => 'test@localhost')));
- $this->assertTrue($pp->isEverybodyAllowed(1));
+ $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest1')));
+ $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1)));
+ $this->assertTrue($userModel->update(array('id' => 1, 'email' => 'test@localhost')));
+ $this->assertTrue($projectUserRoleModel->addUser(1, 1, Role::PROJECT_MANAGER));
- $n->saveSettings(1, array(
+ $userNotificationModel->saveSettings(1, array(
'notifications_enabled' => 1,
'notifications_filter' => UserNotificationFilterModel::FILTER_NONE,
'notification_types' => array('web' => 1, 'email' => 1),
@@ -259,6 +225,6 @@ class UserNotificationTest extends Base
->with($this->equalTo('web'))
->will($this->returnValue($notifier));
- $n->sendNotifications(TaskModel::EVENT_CREATE, array('task' => $tf->getDetails(1)));
+ $userNotificationModel->sendNotifications(TaskModel::EVENT_CREATE, array('task' => $taskFinderModel->getDetails(1)));
}
}