true, RoleManager::CAP_EXPORT_PAYMENTS => true, // A non-instructor cap the admin holds is irrelevant here. RoleManager::CAP_MANAGE_POLICIES => true, ]); self::assertContains(RoleManager::CAP_MANAGE_OFFERINGS, $grantable); self::assertContains(RoleManager::CAP_EXPORT_PAYMENTS, $grantable); self::assertNotContains(RoleManager::CAP_MANAGE_QUESTIONS, $grantable); self::assertNotContains(RoleManager::CAP_MANAGE_POLICIES, $grantable); } public function testGrantableExcludesCapsTheAdminLacksOrHasDisabled(): void { self::assertSame([], InstructorCapabilities::grantable([ RoleManager::CAP_MANAGE_OFFERINGS => false, ])); self::assertSame([], InstructorCapabilities::grantable([])); } public function testResolveMapsEachGrantableCapToWhetherItWasSubmitted(): void { $resolved = InstructorCapabilities::resolve( [RoleManager::CAP_MANAGE_OFFERINGS], [RoleManager::CAP_MANAGE_OFFERINGS, RoleManager::CAP_EXPORT_PAYMENTS] ); self::assertTrue($resolved[RoleManager::CAP_MANAGE_OFFERINGS]); self::assertFalse($resolved[RoleManager::CAP_EXPORT_PAYMENTS]); } public function testResolveIgnoresSubmittedCapsOutsideTheGrantableSet(): void { // The form posts a cap the admin may not grant; it must be dropped, so a // studio admin can never assign a capability it does not itself hold. $resolved = InstructorCapabilities::resolve( [RoleManager::CAP_MANAGE_QUESTIONS, RoleManager::CAP_MANAGE_POLICIES], [RoleManager::CAP_MANAGE_OFFERINGS] ); self::assertSame([RoleManager::CAP_MANAGE_OFFERINGS => false], $resolved); } }