/** * Does the managing of permissions work? * * That means, calls to grant, revoke, grantAll and revokeAll. * */ public function testManagingPermissions() { $target = new EmployeePermissions(); $target->grant(EmployeePermissions::JOBS_CREATE); $this->assertTrue($target->isAllowed(EmployeePermissions::JOBS_CREATE)); $target->revoke(EmployeePermissions::JOBS_CREATE); $this->assertFalse($target->isAllowed(EmployeePermissions::JOBS_CREATE)); // Test setting multiple permissions at once $target->setPermissions(18); // reset $target->grant(EmployeePermissions::JOBS_CHANGE, EmployeePermissions::APPLICATIONS_CHANGE); $this->assertTrue($target->isAllowed(EmployeePermissions::JOBS_CHANGE)); $this->assertTrue($target->isAllowed(EmployeePermissions::APPLICATIONS_CHANGE)); $target->revoke(EmployeePermissions::JOBS_CHANGE, EmployeePermissions::APPLICATIONS_CHANGE); $this->assertFalse($target->isAllowed(EmployeePermissions::JOBS_CHANGE)); $this->assertFalse($target->isAllowed(EmployeePermissions::APPLICATIONS_CHANGE)); // test grantAll / revokeAll $target->grantAll(); $this->assertEquals($target->getPermissions(), EmployeePermissions::ALL); $target->revokeAll(); $this->assertEquals($target->getPermissions(), EmployeePermissions::NONE); }