public function testAllowUser() { $p = new Project($this->container); $pp = new ProjectPermission($this->container); $user = new User($this->container); $this->assertNotFalse($user->create(array('username' => 'unittest', 'password' => 'unittest'))); // We create a project $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); $this->assertEmpty($pp->getMemberProjects(1)); $this->assertEmpty($pp->getMemberProjects(2)); $this->assertEmpty($pp->getMemberProjectIds(1)); $this->assertEmpty($pp->getMemberProjectIds(2)); $this->assertEmpty($pp->getActiveMemberProjectIds(1)); $this->assertEmpty($pp->getActiveMemberProjectIds(2)); $this->assertEmpty($pp->getActiveMemberProjects(1)); $this->assertEmpty($pp->getActiveMemberProjects(2)); // We allow the admin user $this->assertTrue($pp->addMember(1, 1)); $this->assertTrue($pp->addMember(1, 2)); // Non-existant project $this->assertFalse($pp->addMember(50, 1)); // Non-existant user $this->assertFalse($pp->addMember(1, 50)); // Both users should be allowed $this->assertEquals(array('1' => 'admin', '2' => 'unittest'), $pp->getMembers(1)); $this->assertTrue($pp->isUserAllowed(1, 1)); $this->assertTrue($pp->isUserAllowed(1, 2)); $this->assertNotEmpty($pp->getMemberProjects(1)); $this->assertNotEmpty($pp->getMemberProjects(2)); $this->assertNotEmpty($pp->getMemberProjectIds(1)); $this->assertNotEmpty($pp->getMemberProjectIds(2)); $this->assertNotEmpty($pp->getActiveMemberProjectIds(1)); $this->assertNotEmpty($pp->getActiveMemberProjectIds(2)); $this->assertNotEmpty($pp->getActiveMemberProjects(1)); $this->assertNotEmpty($pp->getActiveMemberProjects(2)); }