summaryrefslogtreecommitdiff
path: root/tests/units/Model/ProjectRoleModelTest.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-09-10 22:37:57 -0400
committerFrederic Guillot <fred@kanboard.net>2016-09-10 22:37:57 -0400
commit44f680cf2f1463721eb5bdb7eda4d3b339e63ba9 (patch)
treeed4aeef8b32dbd76277dacf864b028677bc10809 /tests/units/Model/ProjectRoleModelTest.php
parent75470c72428c8d8f278d160369558ab31b137fb1 (diff)
Add ui to create new custom project roles and column restrictions
Diffstat (limited to 'tests/units/Model/ProjectRoleModelTest.php')
-rw-r--r--tests/units/Model/ProjectRoleModelTest.php72
1 files changed, 71 insertions, 1 deletions
diff --git a/tests/units/Model/ProjectRoleModelTest.php b/tests/units/Model/ProjectRoleModelTest.php
index ce1392c2..5dd78e20 100644
--- a/tests/units/Model/ProjectRoleModelTest.php
+++ b/tests/units/Model/ProjectRoleModelTest.php
@@ -1,7 +1,12 @@
<?php
+use Kanboard\Core\Security\Role;
+use Kanboard\Model\GroupMemberModel;
+use Kanboard\Model\GroupModel;
+use Kanboard\Model\ProjectGroupRoleModel;
use Kanboard\Model\ProjectModel;
use Kanboard\Model\ProjectRoleModel;
+use Kanboard\Model\ProjectUserRoleModel;
require_once __DIR__.'/../Base.php';
@@ -46,14 +51,79 @@ class ProjectRoleModelTest extends Base
$this->assertTrue($projectRoleModel->update(1, 1, 'Role B'));
}
- public function testRemove()
+ public function testRemoveWithUserRole()
{
$projectModel = new ProjectModel($this->container);
$projectRoleModel = new ProjectRoleModel($this->container);
+ $projectUserRoleModel = new ProjectUserRoleModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'Test')));
$this->assertEquals(1, $projectRoleModel->create(1, 'Role A'));
+ $this->assertTrue($projectUserRoleModel->addUser(1, 1, 'Role A'));
+ $this->assertEquals('Role A', $projectUserRoleModel->getUserRole(1, 1));
+
+ $this->assertTrue($projectRoleModel->remove(1, 1));
+ $this->assertEmpty($projectRoleModel->getAll(1));
+ $this->assertEquals(Role::PROJECT_MEMBER, $projectUserRoleModel->getUserRole(1, 1));
+ }
+
+ public function testRemoveWithGroupRole()
+ {
+ $projectModel = new ProjectModel($this->container);
+ $projectRoleModel = new ProjectRoleModel($this->container);
+ $projectGroupRoleModel = new ProjectGroupRoleModel($this->container);
+ $groupModel = new GroupModel($this->container);
+ $groupMemberModel = new GroupMemberModel($this->container);
+
+ $this->assertEquals(1, $groupModel->create('Group A'));
+ $this->assertTrue($groupMemberModel->addUser(1, 1));
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'Test')));
+ $this->assertEquals(1, $projectRoleModel->create(1, 'Role A'));
+ $this->assertTrue($projectGroupRoleModel->addGroup(1, 1, 'Role A'));
+ $this->assertEquals('Role A', $projectGroupRoleModel->getUserRole(1, 1));
+
$this->assertTrue($projectRoleModel->remove(1, 1));
$this->assertEmpty($projectRoleModel->getAll(1));
+ $this->assertEquals(Role::PROJECT_MEMBER, $projectGroupRoleModel->getUserRole(1, 1));
+ }
+
+ public function testGetRoleListWithoutCustomRoles()
+ {
+ $projectModel = new ProjectModel($this->container);
+ $projectRoleModel = new ProjectRoleModel($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'Test')));
+
+ $roles = $projectRoleModel->getList(1);
+ $this->assertCount(3, $roles);
+ $this->assertEquals('Project Manager', $roles[Role::PROJECT_MANAGER]);
+ }
+
+ public function testGetRoleListWithCustomRoles()
+ {
+ $projectModel = new ProjectModel($this->container);
+ $projectRoleModel = new ProjectRoleModel($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'Test')));
+ $this->assertEquals(1, $projectRoleModel->create(1, 'Role A'));
+
+ $roles = $projectRoleModel->getList(1);
+ $this->assertCount(4, $roles);
+ $this->assertEquals('Role A', $roles['Role A']);
+ }
+
+ public function testGetById()
+ {
+ $projectModel = new ProjectModel($this->container);
+ $projectRoleModel = new ProjectRoleModel($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'Test')));
+ $this->assertEquals(1, $projectRoleModel->create(1, 'Role A'));
+
+ $role = $projectRoleModel->getById(1, 1);
+ $this->assertEquals(1, $role['role_id']);
+ $this->assertEquals(1, $role['project_id']);
+ $this->assertEquals('Role A', $role['role']);
}
}