public function testCloneProjectWithUsers()
 {
     $p = new Project($this->container);
     $c = new Category($this->container);
     $pp = new ProjectPermission($this->container);
     $u = new User($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, $p->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));
 }
Exemplo n.º 2
0
 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));
 }
Exemplo n.º 3
0
 public function testPageAccessNotMember()
 {
     $acl = new Acl($this->container);
     $p = new Project($this->container);
     $pp = new ProjectPermission($this->container);
     $u = new User($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 member
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
     $this->assertEquals(2, $p->create(array('name' => 'UnitTest2')));
     $this->assertFalse($pp->isMember(1, 2));
     $this->assertFalse($pp->isManager(1, 2));
     $session = new Session();
     $session['user'] = array('id' => 2, 'is_admin' => false);
     $this->assertFalse($acl->isAllowed('board', 'show', 2));
     $this->assertFalse($acl->isAllowed('board', 'show', 1));
     $this->assertFalse($acl->isAllowed('task', 'show', 1));
     $this->assertFalse($acl->isAllowed('task', 'update', 1));
     $this->assertFalse($acl->isAllowed('project', 'show', 1));
     $this->assertFalse($acl->isAllowed('config', 'application', 1));
     $this->assertFalse($acl->isAllowed('project', 'users', 1));
     $this->assertFalse($acl->isAllowed('task', 'remove', 1));
     $this->assertTrue($acl->isAllowed('app', 'index', 1));
 }
Exemplo n.º 4
0
 public function testIsProjectManagementAllowedForProjectManager()
 {
     $h = new User($this->container);
     $p = new Project($this->container);
     $pp = new ProjectPermission($this->container);
     $u = new UserModel($this->container);
     $session = new Session();
     // 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
     $session['user'] = array('id' => 2, 'is_admin' => false, 'is_project_admin' => false);
     $this->assertTrue($h->isProjectManagementAllowed(1));
 }