Beispiel #1
0
 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));
 }
 public function testCloneProjectWithUsers()
 {
     $p = new Project($this->container);
     $c = new Category($this->container);
     $pp = new ProjectPermission($this->container);
     $u = new User($this->container);
     $pd = new ProjectDuplication($this->container);
     $this->assertEquals(2, $u->create(array('username' => 'unittest1', 'password' => 'unittest')));
     $this->assertEquals(3, $u->create(array('username' => 'unittest2', 'password' => 'unittest')));
     $this->assertEquals(4, $u->create(array('username' => 'unittest3', 'password' => 'unittest')));
     $this->assertEquals(1, $p->create(array('name' => 'P1')));
     $this->assertTrue($pp->addMember(1, 2));
     $this->assertTrue($pp->addMember(1, 4));
     $this->assertTrue($pp->addManager(1, 3));
     $this->assertTrue($pp->isMember(1, 2));
     $this->assertTrue($pp->isMember(1, 3));
     $this->assertTrue($pp->isMember(1, 4));
     $this->assertFalse($pp->isManager(1, 2));
     $this->assertTrue($pp->isManager(1, 3));
     $this->assertFalse($pp->isManager(1, 4));
     $this->assertEquals(2, $pd->duplicate(1));
     $project = $p->getById(2);
     $this->assertNotEmpty($project);
     $this->assertEquals('P1 (Clone)', $project['name']);
     $this->assertEquals(3, count($pp->getMembers(2)));
     $this->assertTrue($pp->isMember(2, 2));
     $this->assertTrue($pp->isMember(2, 3));
     $this->assertTrue($pp->isMember(2, 4));
     $this->assertFalse($pp->isManager(2, 2));
     $this->assertTrue($pp->isManager(2, 3));
     $this->assertFalse($pp->isManager(2, 4));
 }
 public function testManager()
 {
     $p = new Project($this->container);
     $pp = new ProjectPermission($this->container);
     $u = new User($this->container);
     $this->assertEquals(2, $u->create(array('username' => 'unittest', 'password' => 'unittest')));
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
     $this->assertFalse($pp->isMember(1, 2));
     $this->assertFalse($pp->isManager(1, 2));
     $this->assertEquals(2, $p->create(array('name' => 'UnitTest2'), 1, true));
     $this->assertFalse($pp->isMember(2, 2));
     $this->assertFalse($pp->isManager(2, 2));
     $this->assertEquals(3, $p->create(array('name' => 'UnitTest3'), 2, true));
     $this->assertTrue($pp->isMember(3, 2));
     $this->assertTrue($pp->isManager(3, 2));
     $this->assertEquals(4, $p->create(array('name' => 'UnitTest4')));
     $this->assertTrue($pp->addManager(4, 2));
     $this->assertTrue($pp->isMember(4, 2));
     $this->assertTrue($pp->isManager(4, 2));
     $this->assertEquals(5, $p->create(array('name' => 'UnitTest5')));
     $this->assertTrue($pp->addMember(5, 2));
     $this->assertTrue($pp->changeRole(5, 2, 1));
     $this->assertTrue($pp->isMember(5, 2));
     $this->assertTrue($pp->isManager(5, 2));
     $this->assertTrue($pp->changeRole(5, 2, 0));
     $this->assertTrue($pp->isMember(5, 2));
     $this->assertFalse($pp->isManager(5, 2));
 }