summaryrefslogtreecommitdiff
path: root/tests/integration/ProjectPermissionTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/integration/ProjectPermissionTest.php')
-rw-r--r--tests/integration/ProjectPermissionTest.php107
1 files changed, 66 insertions, 41 deletions
diff --git a/tests/integration/ProjectPermissionTest.php b/tests/integration/ProjectPermissionTest.php
index b06ad4ad..3ceda07d 100644
--- a/tests/integration/ProjectPermissionTest.php
+++ b/tests/integration/ProjectPermissionTest.php
@@ -1,64 +1,89 @@
<?php
-require_once __DIR__.'/Base.php';
+require_once __DIR__.'/BaseIntegrationTest.php';
-class ProjectPermissionTest extends Base
+class ProjectPermissionTest extends BaseIntegrationTest
{
- public function testGetProjectUsers()
- {
- $this->assertNotFalse($this->app->createProject('Test'));
- $this->assertNotFalse($this->app->createGroup('Test'));
-
- $projectId = $this->getProjectId();
- $groupId = $this->getGroupId();
+ protected $projectName = 'Project with permission';
+ protected $username = 'user-project-permission';
+ protected $groupName1 = 'My group A for project permission';
+ protected $groupName2 = 'My group B for project permission';
- $this->assertTrue($this->app->addGroupMember($projectId, $groupId));
- $this->assertSame(array(), $this->app->getProjectUsers($projectId));
+ public function testAll()
+ {
+ $this->assertCreateTeamProject();
+ $this->assertCreateGroups();
+ $this->assertCreateUser();
+
+ $this->assertAddProjectUser();
+ $this->assertGetProjectUsers();
+ $this->assertGetAssignableUsers();
+ $this->assertChangeProjectUserRole();
+ $this->assertRemoveProjectUser();
+
+ $this->assertAddProjectGroup();
+ $this->assertGetProjectUsers();
+ $this->assertGetAssignableUsers();
+ $this->assertChangeProjectGroupRole();
+ $this->assertRemoveProjectGroup();
}
- public function testProjectUser()
+ public function assertAddProjectUser()
{
- $projectId = $this->getProjectId();
- $this->assertTrue($this->app->addProjectUser($projectId, 1));
-
- $users = $this->app->getProjectUsers($projectId);
- $this->assertCount(1, $users);
- $this->assertEquals('admin', $users[1]);
+ $this->assertTrue($this->app->addProjectUser($this->projectId, $this->userId));
+ }
- $users = $this->app->getAssignableUsers($projectId);
- $this->assertCount(1, $users);
- $this->assertEquals('admin', $users[1]);
+ public function assertGetProjectUsers()
+ {
+ $members = $this->app->getProjectUsers($this->projectId);
+ $this->assertCount(1, $members);
+ $this->assertArrayHasKey($this->userId, $members);
+ $this->assertEquals($this->username, $members[$this->userId]);
+ }
- $this->assertTrue($this->app->changeProjectUserRole($projectId, 1, 'project-viewer'));
+ public function assertGetAssignableUsers()
+ {
+ $members = $this->app->getAssignableUsers($this->projectId);
+ $this->assertCount(1, $members);
+ $this->assertArrayHasKey($this->userId, $members);
+ $this->assertEquals($this->username, $members[$this->userId]);
+ }
- $users = $this->app->getAssignableUsers($projectId);
- $this->assertCount(0, $users);
+ public function assertChangeProjectUserRole()
+ {
+ $this->assertTrue($this->app->changeProjectUserRole($this->projectId, $this->userId, 'project-viewer'));
- $this->assertTrue($this->app->removeProjectUser($projectId, 1));
- $this->assertSame(array(), $this->app->getProjectUsers($projectId));
+ $members = $this->app->getAssignableUsers($this->projectId);
+ $this->assertCount(0, $members);
}
- public function testProjectGroup()
+ public function assertRemoveProjectUser()
{
- $projectId = $this->getProjectId();
- $groupId = $this->getGroupId();
+ $this->assertTrue($this->app->removeProjectUser($this->projectId, $this->userId));
- $this->assertTrue($this->app->addProjectGroup($projectId, $groupId));
+ $members = $this->app->getProjectUsers($this->projectId);
+ $this->assertCount(0, $members);
+ }
- $users = $this->app->getProjectUsers($projectId);
- $this->assertCount(1, $users);
- $this->assertEquals('admin', $users[1]);
+ public function assertAddProjectGroup()
+ {
+ $this->assertTrue($this->app->addGroupMember($this->groupId1, $this->userId));
+ $this->assertTrue($this->app->addProjectGroup($this->projectId, $this->groupId1));
+ }
- $users = $this->app->getAssignableUsers($projectId);
- $this->assertCount(1, $users);
- $this->assertEquals('admin', $users[1]);
+ public function assertChangeProjectGroupRole()
+ {
+ $this->assertTrue($this->app->changeProjectGroupRole($this->projectId, $this->groupId1, 'project-viewer'));
- $this->assertTrue($this->app->changeProjectGroupRole($projectId, $groupId, 'project-viewer'));
+ $members = $this->app->getAssignableUsers($this->projectId);
+ $this->assertCount(0, $members);
+ }
- $users = $this->app->getAssignableUsers($projectId);
- $this->assertCount(0, $users);
+ public function assertRemoveProjectGroup()
+ {
+ $this->assertTrue($this->app->removeProjectGroup($this->projectId, $this->groupId1));
- $this->assertTrue($this->app->removeProjectGroup($projectId, 1));
- $this->assertSame(array(), $this->app->getProjectUsers($projectId));
+ $members = $this->app->getProjectUsers($this->projectId);
+ $this->assertCount(0, $members);
}
}