From f3e16da4ac8eb5f06c7f8a0aed49fd3dd11817ec Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Thu, 28 Jul 2016 16:56:37 -0400 Subject: Allow users to see inactive projects --- tests/units/Model/ProjectPermissionTest.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests') diff --git a/tests/units/Model/ProjectPermissionTest.php b/tests/units/Model/ProjectPermissionTest.php index c9e0a481..a9f8ab04 100644 --- a/tests/units/Model/ProjectPermissionTest.php +++ b/tests/units/Model/ProjectPermissionTest.php @@ -267,6 +267,29 @@ class ProjectPermissionTest extends Base $this->assertEquals(array(1), $projectPermission->getActiveProjectIds(3)); } + public function testGetProjectIds() + { + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $userRoleModel = new ProjectUserRoleModel($this->container); + $projectPermission = new ProjectPermissionModel($this->container); + + $this->assertEquals(2, $userModel->create(array('username' => 'user 1'))); + $this->assertEquals(3, $userModel->create(array('username' => 'user 2'))); + + $this->assertEquals(1, $projectModel->create(array('name' => 'Project 1'))); + $this->assertEquals(2, $projectModel->create(array('name' => 'Project 2', 'is_active' => 0))); + + $this->assertTrue($userRoleModel->addUser(1, 2, Role::PROJECT_MEMBER)); + $this->assertTrue($userRoleModel->addUser(2, 2, Role::PROJECT_MEMBER)); + $this->assertTrue($userRoleModel->addUser(1, 3, Role::PROJECT_MEMBER)); + $this->assertTrue($userRoleModel->addUser(2, 3, Role::PROJECT_MEMBER)); + + $this->assertEmpty($projectPermission->getProjectIds(1)); + $this->assertEquals(array(1, 2), $projectPermission->getProjectIds(2)); + $this->assertEquals(array(1, 2), $projectPermission->getProjectIds(3)); + } + public function testDuplicate() { $userModel = new UserModel($this->container); -- cgit v1.2.3