コード例 #1
0
ファイル: UserHelperTest.php プロジェクト: orlov0562/kanboard
 public function testHasProjectAccessForProjectViewers()
 {
     $helper = new User($this->container);
     $user = new UserModel($this->container);
     $project = new Project($this->container);
     $projectUserRole = new ProjectUserRole($this->container);
     $this->container['sessionStorage']->user = array('id' => 2, 'role' => Role::APP_USER);
     $this->assertEquals(1, $project->create(array('name' => 'My project')));
     $this->assertEquals(2, $project->create(array('name' => 'My project')));
     $this->assertEquals(2, $user->create(array('username' => 'user')));
     $this->assertTrue($projectUserRole->addUser(1, 2, Role::PROJECT_VIEWER));
     $this->assertFalse($helper->hasProjectAccess('ProjectEdit', 'edit', 1));
     $this->assertTrue($helper->hasProjectAccess('board', 'show', 1));
     $this->assertTrue($helper->hasProjectAccess('task', 'show', 1));
     $this->assertFalse($helper->hasProjectAccess('taskcreation', 'save', 1));
     $this->assertFalse($helper->hasProjectAccess('ProjectEdit', 'edit', 2));
     $this->assertFalse($helper->hasProjectAccess('board', 'show', 2));
     $this->assertFalse($helper->hasProjectAccess('task', 'show', 2));
     $this->assertFalse($helper->hasProjectAccess('taskcreation', 'save', 2));
 }
コード例 #2
0
ファイル: UserHelperTest.php プロジェクト: Folcky/kanboard
 public function testIsProjectManagementAllowedForProjectManager()
 {
     $h = new User($this->container);
     $p = new Project($this->container);
     $pp = new ProjectPermission($this->container);
     $u = new UserModel($this->container);
     // We create our user
     $this->assertEquals(2, $u->create(array('username' => 'unittest', 'password' => 'unittest')));
     // We create a project and set our user as project member
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
     $this->assertTrue($pp->addManager(1, 2));
     $this->assertTrue($pp->isMember(1, 2));
     $this->assertTrue($pp->isManager(1, 2));
     // We fake a session for him
     $this->container['sessionStorage']->user = array('id' => 2, 'is_admin' => false, 'is_project_admin' => false);
     $this->assertTrue($h->isProjectManagementAllowed(1));
 }