public function testThrowsExceptionWhenConfigIsNotFound() { $repository = new RepositoryFake(); $options = new ModuleOptions([]); $key = ModuleOptions::KEY_PERMISSION_REJECT; $this->setExpectedException('Athene2\\Versioning\\Exception\\RuntimeException'); $this->assertEquals('checkout', $options->getPermission($repository, $key)); }
/** * @param RepositoryInterface $repository * @param RevisionInterface $revision * @param string $event * @return void * @throws UnauthorizedException */ protected function hasPermission(RepositoryInterface $repository, RevisionInterface $revision, $event) { $permission = $this->moduleOptions->getPermission($repository, $event); if (!$this->authorizationService->isGranted($permission, $revision)) { switch ($event) { case VersioningEvent::REJECT: $event = VersioningEvent::REJECT_UNAUTHORIZED; break; case VersioningEvent::COMMIT: $event = VersioningEvent::COMMIT_UNAUTHORIZED; break; case VersioningEvent::CHECKOUT: $event = VersioningEvent::CHECKOUT_UNAUTHORIZED; break; } $this->triggerEvent($event, $repository, $revision); throw new UnauthorizedException(sprintf('You are missing permission "%s" for this event %s.', $permission, $event)); } }