コード例 #1
0
 public function testUsersList()
 {
     $p = new Project($this->container);
     $pp = new ProjectPermission($this->container);
     $user = new User($this->container);
     $user->create(array('username' => 'unittest', 'password' => 'unittest'));
     // We create project
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
     // No restriction, we should have no body
     $this->assertEquals(array('Unassigned'), $pp->getMemberList(1));
     // We allow only the regular user
     $this->assertTrue($pp->allowUser(1, 2));
     $this->assertEquals(array(0 => 'Unassigned', 2 => 'unittest'), $pp->getMemberList(1));
     // We allow the admin user
     $this->assertTrue($pp->allowUser(1, 1));
     $this->assertEquals(array(0 => 'Unassigned', 1 => 'admin', 2 => 'unittest'), $pp->getMemberList(1));
     // We revoke only the regular user
     $this->assertTrue($pp->revokeUser(1, 2));
     $this->assertEquals(array(0 => 'Unassigned', 1 => 'admin'), $pp->getMemberList(1));
     // We revoke only the admin user, we should have everybody
     $this->assertTrue($pp->revokeUser(1, 1));
     $this->assertEquals(array(0 => 'Unassigned'), $pp->getMemberList(1));
 }