diff --git a/composer.json b/composer.json index 12e3940e..19093452 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,8 @@ "laminas/laminas-mvc": "^3.0", "laminas/laminas-servicemanager": "^3.0", "laminas/laminas-permissions-rbac": "^3.0", - "doctrine/persistence": "^2.1" + "doctrine/persistence": "^2.1", + "lm-commons/lmc-rbac": "2.x-dev" }, "require-dev": { "laminas/laminas-authentication": "^2.2", @@ -58,9 +59,6 @@ "laminas/laminas-developer-tools": "if you want to show information about the roles", "doctrine/doctrine-module": "if you want to use Doctrine role provider" }, - "replace": { - "laminas-commons/lmc-rbac-mvc": "3.0.1" - }, "autoload": { "psr-4": { "LmcRbacMvc\\": "src" diff --git a/config/module.config.php b/config/module.config.php deleted file mode 100644 index bc856b74..00000000 --- a/config/module.config.php +++ /dev/null @@ -1,95 +0,0 @@ - [ - 'factories' => [ - /* Factories that do not map to a class */ - 'LmcRbacMvc\Guards' => \LmcRbacMvc\Factory\GuardsFactory::class, - - /* Factories that map to a class */ - \LmcRbacMvc\Assertion\AssertionPluginManager::class => \LmcRbacMvc\Factory\AssertionPluginManagerFactory::class, - // TODO Remove RbacCollector once it is moved to a separate library - \LmcRbacMvc\Collector\RbacCollector::class => \Laminas\ServiceManager\Factory\InvokableFactory::class, - \LmcRbacMvc\Guard\GuardPluginManager::class => \LmcRbacMvc\Factory\GuardPluginManagerFactory::class, - \LmcRbacMvc\Identity\AuthenticationIdentityProvider::class => \LmcRbacMvc\Factory\AuthenticationIdentityProviderFactory::class, - \LmcRbacMvc\Options\ModuleOptions::class => \LmcRbacMvc\Factory\ModuleOptionsFactory::class, - \LmcRbacMvc\Role\RoleProviderPluginManager::class => \LmcRbacMvc\Factory\RoleProviderPluginManagerFactory::class, - \LmcRbacMvc\Service\AuthorizationService::class => \LmcRbacMvc\Factory\AuthorizationServiceFactory::class, - \LmcRbacMvc\Service\RoleService::class => \LmcRbacMvc\Factory\RoleServiceFactory::class, - \LmcRbacMvc\View\Strategy\RedirectStrategy::class => \LmcRbacMvc\Factory\RedirectStrategyFactory::class, - \LmcRbacMvc\View\Strategy\UnauthorizedStrategy::class => \LmcRbacMvc\Factory\UnauthorizedStrategyFactory::class, - ], - ], - - 'view_helpers' => [ - 'factories' => [ - \LmcRbacMvc\View\Helper\IsGranted::class => \LmcRbacMvc\Factory\IsGrantedViewHelperFactory::class, - \LmcRbacMvc\View\Helper\HasRole::class => \LmcRbacMvc\Factory\HasRoleViewHelperFactory::class, - ], - 'aliases' => [ - 'isGranted' => \LmcRbacMvc\View\Helper\IsGranted::class, - 'hasRole' => \LmcRbacMvc\View\Helper\HasRole::class, - ] - ], - - 'controller_plugins' => [ - 'factories' => [ - \LmcRbacMvc\Mvc\Controller\Plugin\IsGranted::class => \LmcRbacMvc\Factory\IsGrantedPluginFactory::class, - ], - 'aliases' => [ - 'isGranted' => \LmcRbacMvc\Mvc\Controller\Plugin\IsGranted::class, - ] - ], - - 'view_manager' => [ - 'template_map' => [ - 'error/403' => __DIR__ . '/../view/error/403.phtml', - 'laminas-developer-tools/toolbar/lmc-rbac' => __DIR__ . '/../view/laminas-developer-tools/toolbar/lmc-rbac.phtml' - ] - ], - - /* - * Developer tools are now provided by the companion module LmcRbacMvcDevTools - * You can still use the config below but you are encouraged to use the new module - * - 'laminas-developer-tools' => [ - 'profiler' => [ - 'collectors' => [ - 'lmc_rbac' => \LmcRbacMvc\Collector\RbacCollector::class, - ], - ], - 'toolbar' => [ - 'entries' => [ - 'lmc_rbac' => 'laminas-developer-tools/toolbar/lmc-rbac', - ], - ], - ], - */ - - 'lmc_rbac' => [ - // Guard plugin manager - 'guard_manager' => [], - - // Role provider plugin manager - 'role_provider_manager' => [], - - // Assertion plugin manager - 'assertion_manager' => [] - ] -]; diff --git a/docs/docs/cookbook.md b/docs/docs/cookbook.md index 4b2551c3..e5d5ecbb 100644 --- a/docs/docs/cookbook.md +++ b/docs/docs/cookbook.md @@ -360,7 +360,7 @@ check for the `deletePost` permission. We don't want others to delete our previo called `assertion_map`. In this map we glue `assertions` and `permissions` together. ```php -// module.config.php or wherever you configure your RBAC stuff +// config/autoload/lmc_rbac.global.php or wherever your LmcRbac configuration file is return [ 'lmc_rbac' => [ 'assertion_map' => [ @@ -376,7 +376,7 @@ However, some assertions may need dependencies. You can manually configure the a shown below: ```php -// module.config.php or wherever you configure your RBAC stuff +// config/autoload/lmc_rbac.global.php or wherever your LmcRbac configuration file is return [ 'lmc_rbac' => [ // ... other rbac stuff diff --git a/src/Collector/RbacCollector.php b/src/Collector/RbacCollector.php index 77b40a6a..6ed4d3f8 100644 --- a/src/Collector/RbacCollector.php +++ b/src/Collector/RbacCollector.php @@ -29,7 +29,7 @@ use Laminas\DeveloperTools\Collector\CollectorInterface; use LmcRbacMvc\Options\ModuleOptions; use LmcRbacMvc\Service\RoleService; -use LmcRbacMvc\Exception\InvalidArgumentException; +use LmcRbac\Exception\InvalidArgumentException; /** * RbacCollector diff --git a/src/ConfigProvider.php b/src/ConfigProvider.php new file mode 100644 index 00000000..71b099f6 --- /dev/null +++ b/src/ConfigProvider.php @@ -0,0 +1,90 @@ + $this->getDependencies(), + 'view_helpers' => $this->getViewHelperConfig(), + 'controller_plugins' => $this->getControllerPluginConfig(), + 'view_manager' => $this->getViewManagerConfig(), + 'lmc_rbac' => $this->getModuleConfig(), + ]; + } + + public function getDependencies(): array + { + return [ + 'factories' => [ + /* Factories that do not map to a class */ + 'LmcRbacMvc\Guards' => \LmcRbacMvc\Factory\GuardsFactory::class, + + /* Factories that map to a class */ + \LmcRbacMvc\Assertion\AssertionPluginManager::class => \LmcRbacMvc\Factory\AssertionPluginManagerFactory::class, + // TODO Remove RbacCollector once it is moved to a separate library + \LmcRbacMvc\Collector\RbacCollector::class => \Laminas\ServiceManager\Factory\InvokableFactory::class, + \LmcRbacMvc\Guard\GuardPluginManager::class => \LmcRbacMvc\Factory\GuardPluginManagerFactory::class, + \LmcRbacMvc\Identity\AuthenticationIdentityProvider::class => \LmcRbacMvc\Factory\AuthenticationIdentityProviderFactory::class, + \LmcRbacMvc\Options\ModuleOptions::class => \LmcRbacMvc\Factory\ModuleOptionsFactory::class, + \LmcRbacMvc\Role\RoleProviderPluginManager::class => \LmcRbacMvc\Factory\RoleProviderPluginManagerFactory::class, + \LmcRbacMvc\Service\AuthorizationService::class => \LmcRbacMvc\Factory\AuthorizationServiceFactory::class, + \LmcRbacMvc\Service\RoleService::class => \LmcRbacMvc\Factory\RoleServiceFactory::class, + \LmcRbacMvc\View\Strategy\RedirectStrategy::class => \LmcRbacMvc\Factory\RedirectStrategyFactory::class, + \LmcRbacMvc\View\Strategy\UnauthorizedStrategy::class => \LmcRbacMvc\Factory\UnauthorizedStrategyFactory::class, + ], + ]; + } + + public function getModuleConfig(): array + { + return [ + // Guard plugin manager + 'guard_manager' => [], + + // Role provider plugin manager + 'role_provider_manager' => [], + + // Assertion plugin manager + 'assertion_manager' => [] + ]; + } + + public function getControllerPluginConfig(): array + { + return [ + 'factories' => [ + \LmcRbacMvc\Mvc\Controller\Plugin\IsGranted::class => \LmcRbacMvc\Factory\IsGrantedPluginFactory::class, + ], + 'aliases' => [ + 'isGranted' => \LmcRbacMvc\Mvc\Controller\Plugin\IsGranted::class, + ], + ]; + } + + public function getViewHelperConfig(): array + { + return [ + 'factories' => [ + \LmcRbacMvc\View\Helper\IsGranted::class => \LmcRbacMvc\Factory\IsGrantedViewHelperFactory::class, + \LmcRbacMvc\View\Helper\HasRole::class => \LmcRbacMvc\Factory\HasRoleViewHelperFactory::class, + ], + 'aliases' => [ + 'isGranted' => \LmcRbacMvc\View\Helper\IsGranted::class, + 'hasRole' => \LmcRbacMvc\View\Helper\HasRole::class, + ], + ]; + } + + public function getViewManagerConfig(): array + { + return [ + 'template_map' => [ + 'error/403' => __DIR__ . '/../view/error/403.phtml', + 'laminas-developer-tools/toolbar/lmc-rbac' => __DIR__ . '/../view/laminas-developer-tools/toolbar/lmc-rbac.phtml' + ], + ]; + } +} diff --git a/src/Exception/ExceptionInterface.php b/src/Exception/ExceptionInterface.php index 3d07d41a..79d894e1 100644 --- a/src/Exception/ExceptionInterface.php +++ b/src/Exception/ExceptionInterface.php @@ -23,6 +23,7 @@ * * @author Michaël Gallego * @license MIT + * @deprecated Use LmcRbac\Exception\ExceptionInterface instead */ interface ExceptionInterface { diff --git a/src/Exception/InvalidArgumentException.php b/src/Exception/InvalidArgumentException.php index 65a03edc..64b639de 100644 --- a/src/Exception/InvalidArgumentException.php +++ b/src/Exception/InvalidArgumentException.php @@ -18,14 +18,13 @@ namespace LmcRbacMvc\Exception; -use InvalidArgumentException as BaseInvalidArgumentException; - /** * InvalidArgumentException * * @author Michaël Gallego * @license MIT + * @deprecated Use LmcRbac\Exception\InvalidArgumentException instead */ -class InvalidArgumentException extends BaseInvalidArgumentException implements ExceptionInterface +class InvalidArgumentException extends \LmcRbac\Exception\InvalidArgumentException { } diff --git a/src/Exception/RoleNotFoundException.php b/src/Exception/RoleNotFoundException.php index 97301870..30fccdb7 100644 --- a/src/Exception/RoleNotFoundException.php +++ b/src/Exception/RoleNotFoundException.php @@ -25,8 +25,9 @@ * * @author Michaël Gallego * @license MIT + * @deprecated Use LmcRbac\Exception\RoleNotFoundException instead */ -class RoleNotFoundException extends BaseRuntimeException implements ExceptionInterface +class RoleNotFoundException extends \LmcRbac\Exception\RoleNotFoundException { /** * @var string diff --git a/src/Exception/RuntimeException.php b/src/Exception/RuntimeException.php index ec9f873d..2cae6a98 100644 --- a/src/Exception/RuntimeException.php +++ b/src/Exception/RuntimeException.php @@ -18,14 +18,13 @@ namespace LmcRbacMvc\Exception; -use RuntimeException as BaseRuntimeException; - /** * RuntimeException * * @author Michaël Gallego * @license MIT + * @deprecated Use LmcRbac\Exception\RuntimeException instead */ -class RuntimeException extends BaseRuntimeException implements ExceptionInterface +class RuntimeException extends \LmcRbac\Exception\RuntimeException { } diff --git a/src/Exception/UnauthorizedException.php b/src/Exception/UnauthorizedException.php index 2f28fa88..f1727951 100644 --- a/src/Exception/UnauthorizedException.php +++ b/src/Exception/UnauthorizedException.php @@ -18,18 +18,14 @@ namespace LmcRbacMvc\Exception; -use RuntimeException as BaseRuntimeException; /** * Unauthorized exception * * @author Michaël Gallego * @license MIT + * @deprecated Use LmcRbac\Exception\UnauthorizedException instead */ -class UnauthorizedException extends BaseRuntimeException implements UnauthorizedExceptionInterface +class UnauthorizedException extends \LmcRbac\Exception\UnauthorizedException { - /** - * @var string - */ - protected $message = 'You are not authorized to access this resource'; } diff --git a/src/Exception/UnauthorizedExceptionInterface.php b/src/Exception/UnauthorizedExceptionInterface.php index 72d3a544..c83a6eb3 100644 --- a/src/Exception/UnauthorizedExceptionInterface.php +++ b/src/Exception/UnauthorizedExceptionInterface.php @@ -23,6 +23,7 @@ * * @author Michaël Gallego * @license MIT + * @deprecated Use LmcRbac\Exception\UnauthorizedExceptionInterface instead */ interface UnauthorizedExceptionInterface extends ExceptionInterface { diff --git a/src/Factory/AuthorizationServiceDelegatorFactory.php b/src/Factory/AuthorizationServiceDelegatorFactory.php index 4900e408..239d5d2e 100644 --- a/src/Factory/AuthorizationServiceDelegatorFactory.php +++ b/src/Factory/AuthorizationServiceDelegatorFactory.php @@ -22,7 +22,7 @@ //use Laminas\ServiceManager\AbstractPluginManager; use Laminas\ServiceManager\Factory\DelegatorFactoryInterface; use Laminas\ServiceManager\ServiceLocatorInterface; -use LmcRbacMvc\Exception\RuntimeException; +use LmcRbac\Exception\RuntimeException; use LmcRbacMvc\Service\AuthorizationService; use LmcRbacMvc\Service\AuthorizationServiceAwareInterface; diff --git a/src/Factory/RoleServiceFactory.php b/src/Factory/RoleServiceFactory.php index 201e0e2b..4fdb742d 100644 --- a/src/Factory/RoleServiceFactory.php +++ b/src/Factory/RoleServiceFactory.php @@ -22,7 +22,6 @@ use Psr\Container\ContainerInterface; use Laminas\ServiceManager\Factory\FactoryInterface; use Laminas\ServiceManager\ServiceLocatorInterface; -use LmcRbacMvc\Exception\RuntimeException; use LmcRbacMvc\Identity\IdentityProviderInterface; use LmcRbacMvc\Options\ModuleOptions; use LmcRbacMvc\Role\RoleProviderInterface; diff --git a/src/Guard/RoutePermissionsGuard.php b/src/Guard/RoutePermissionsGuard.php index 3e44b9bc..5b4f6721 100644 --- a/src/Guard/RoutePermissionsGuard.php +++ b/src/Guard/RoutePermissionsGuard.php @@ -18,7 +18,7 @@ namespace LmcRbacMvc\Guard; use Laminas\Mvc\MvcEvent; -use LmcRbacMvc\Exception\InvalidArgumentException; +use LmcRbac\Exception\InvalidArgumentException; use LmcRbacMvc\Service\AuthorizationServiceInterface; /** diff --git a/src/Module.php b/src/Module.php index 60197ddf..1d937ec2 100644 --- a/src/Module.php +++ b/src/Module.php @@ -35,10 +35,10 @@ class Module implements BootstrapListenerInterface, ConfigProviderInterface /** * {@inheritDoc} */ - public function onBootstrap(EventInterface $event): void + public function onBootstrap(EventInterface $e): void { /* @var Application $application */ - $application = $event->getTarget(); + $application = $e->getTarget(); $serviceManager = $application->getServiceManager(); $eventManager = $application->getEventManager(); @@ -54,8 +54,15 @@ public function onBootstrap(EventInterface $event): void /** * {@inheritDoc} */ - public function getConfig() + public function getConfig(): array { - return include __DIR__ . '/../config/module.config.php'; + $configProvider = new ConfigProvider(); + return [ + 'service_manager' => $configProvider->getDependencies(), + 'view_helpers' => $configProvider->getViewHelperConfig(), + 'controller_plugins' => $configProvider->getControllerPluginConfig(), + 'view_manager' => $configProvider->getViewManagerConfig(), + 'lmc_rbac' => $configProvider->getModuleConfig(), + ]; } } diff --git a/src/Role/ObjectRepositoryRoleProvider.php b/src/Role/ObjectRepositoryRoleProvider.php index b539f2f3..740a9aff 100644 --- a/src/Role/ObjectRepositoryRoleProvider.php +++ b/src/Role/ObjectRepositoryRoleProvider.php @@ -19,7 +19,7 @@ namespace LmcRbacMvc\Role; use Doctrine\Persistence\ObjectRepository; -use LmcRbacMvc\Exception\RoleNotFoundException; +use LmcRbac\Exception\RoleNotFoundException; /** * Role provider that uses Doctrine object repository to fetch roles diff --git a/src/View/Strategy/RedirectStrategy.php b/src/View/Strategy/RedirectStrategy.php index bbbb3c61..6a945320 100644 --- a/src/View/Strategy/RedirectStrategy.php +++ b/src/View/Strategy/RedirectStrategy.php @@ -21,7 +21,7 @@ use Laminas\Authentication\AuthenticationServiceInterface; use Laminas\Http\Response as HttpResponse; use Laminas\Mvc\MvcEvent; -use LmcRbacMvc\Exception\UnauthorizedExceptionInterface; +use LmcRbac\Exception\UnauthorizedExceptionInterface; use LmcRbacMvc\Options\RedirectStrategyOptions; /** diff --git a/src/View/Strategy/UnauthorizedStrategy.php b/src/View/Strategy/UnauthorizedStrategy.php index 980d943b..e87a3bda 100644 --- a/src/View/Strategy/UnauthorizedStrategy.php +++ b/src/View/Strategy/UnauthorizedStrategy.php @@ -21,7 +21,7 @@ use Laminas\Http\Response as HttpResponse; use Laminas\Mvc\MvcEvent; use Laminas\View\Model\ViewModel; -use LmcRbacMvc\Exception\UnauthorizedExceptionInterface; +use LmcRbac\Exception\UnauthorizedExceptionInterface; use LmcRbacMvc\Guard\GuardInterface; use LmcRbacMvc\Options\UnauthorizedStrategyOptions; diff --git a/tests/Collector/RbacCollectorTest.php b/tests/Collector/RbacCollectorTest.php index d4aa219e..6df83a57 100644 --- a/tests/Collector/RbacCollectorTest.php +++ b/tests/Collector/RbacCollectorTest.php @@ -83,7 +83,7 @@ public function testUnserialize() public function testUnserializeThrowsInvalidArgumentException() { - $this->expectException('LmcRbacMvc\Exception\InvalidArgumentException'); + $this->expectException('LmcRbac\Exception\InvalidArgumentException'); $collector = new RbacCollector(); $unserialized = 'not_an_array'; $serialized = serialize($unserialized); @@ -91,7 +91,7 @@ public function testUnserializeThrowsInvalidArgumentException() $collector->unserialize($serialized); } - +/* public function testCollectNothingIfNoApplicationIsSet() { $mvcEvent = new MvcEvent(); @@ -99,7 +99,7 @@ public function testCollectNothingIfNoApplicationIsSet() $this->assertNull($collector->collect($mvcEvent)); } - +*/ public function testCanCollect() { $dataToCollect = [ diff --git a/tests/Factory/AuthorizationServiceDelegatorTest.php b/tests/Factory/AuthorizationServiceDelegatorTest.php index f34341dd..3daa2c4a 100644 --- a/tests/Factory/AuthorizationServiceDelegatorTest.php +++ b/tests/Factory/AuthorizationServiceDelegatorTest.php @@ -145,7 +145,7 @@ function () { $thrown = true; $this->assertStringEndsWith('The service LmcRbacTest\AuthorizationAware must implement AuthorizationServiceAwareInterface.', $e->getMessage()); if ($e->getPrevious()) { - $this->assertInstanceOf('LmcRbacMvc\Exception\RuntimeException', $e->getPrevious()); + $this->assertInstanceOf('LmcRbac\Exception\RuntimeException', $e->getPrevious()); } } diff --git a/tests/Factory/ObjectRepositoryRoleProviderFactoryTest.php b/tests/Factory/ObjectRepositoryRoleProviderFactoryTest.php index 33be3412..f6e473e4 100644 --- a/tests/Factory/ObjectRepositoryRoleProviderFactoryTest.php +++ b/tests/Factory/ObjectRepositoryRoleProviderFactoryTest.php @@ -20,7 +20,7 @@ use Laminas\ServiceManager\Exception\ServiceNotCreatedException; use Laminas\ServiceManager\ServiceManager; -use LmcRbacMvc\Exception\RuntimeException; +use LmcRbac\Exception\RuntimeException; use LmcRbacMvc\Role\RoleProviderPluginManager; /** @@ -88,7 +88,7 @@ public function testThrowExceptionIfNoRoleNamePropertyIsSet() $this->fail( 'LmcRbacMvc\Factory\ObjectRepositoryRoleProviderFactory::createService() :: ' - .'LmcRbacMvc\Exception\RuntimeException was not found in the previous Exceptions' + .'LmcRbac\Exception\RuntimeException was not found in the previous Exceptions' ); } @@ -115,7 +115,7 @@ public function testThrowExceptionIfNoObjectManagerNorObjectRepositoryIsSet() $this->fail( 'LmcRbacMvc\Factory\ObjectRepositoryRoleProviderFactory::createService() :: ' - .'LmcRbacMvc\Exception\RuntimeException was not found in the previous Exceptions' + .'LmcRbac\Exception\RuntimeException was not found in the previous Exceptions' ); } } diff --git a/tests/Guard/ControllerGuardTest.php b/tests/Guard/ControllerGuardTest.php index 2a414f36..d96d50e9 100644 --- a/tests/Guard/ControllerGuardTest.php +++ b/tests/Guard/ControllerGuardTest.php @@ -19,7 +19,7 @@ namespace LmcRbacMvcTest\Guard; use Laminas\Mvc\MvcEvent; -use Laminas\Mvc\Router\RouteMatch as V2RouteMatch; +//use Laminas\Mvc\Router\RouteMatch as V2RouteMatch; use Laminas\Router\RouteMatch; use LmcRbacMvc\Guard\ControllerGuard; use LmcRbacMvc\Guard\GuardInterface; @@ -526,12 +526,15 @@ public function testProperlySetUnauthorizedAndTriggerEventOnUnauthorization() $this->assertTrue($event->propagationIsStopped()); $this->assertEquals(ControllerGuard::GUARD_UNAUTHORIZED, $event->getError()); - $this->assertInstanceOf('LmcRbacMvc\Exception\UnauthorizedException', $event->getParam('exception')); + $this->assertInstanceOf('LmcRbac\Exception\UnauthorizedException', $event->getParam('exception')); } public function createRouteMatch(array $params = []) { + return new RouteMatch($params); + /* $class = class_exists(V2RouteMatch::class) ? V2RouteMatch::class : RouteMatch::class; return new $class($params); + */ } } diff --git a/tests/Guard/ControllerPermissionsGuardTest.php b/tests/Guard/ControllerPermissionsGuardTest.php index 5435e551..cf3defc8 100644 --- a/tests/Guard/ControllerPermissionsGuardTest.php +++ b/tests/Guard/ControllerPermissionsGuardTest.php @@ -19,7 +19,7 @@ namespace LmcRbacMvcTest\Guard; use Laminas\Mvc\MvcEvent; -use Laminas\Mvc\Router\RouteMatch as V2RouteMatch; +//use Laminas\Mvc\Router\RouteMatch as V2RouteMatch; use Laminas\Router\RouteMatch; use LmcRbacMvc\Guard\ControllerGuard; use LmcRbacMvc\Guard\ControllerPermissionsGuard; @@ -512,12 +512,15 @@ public function testProperlySetUnauthorizedAndTriggerEventOnUnauthorization() $this->assertTrue($event->propagationIsStopped()); $this->assertEquals(ControllerGuard::GUARD_UNAUTHORIZED, $event->getError()); - $this->assertInstanceOf('LmcRbacMvc\Exception\UnauthorizedException', $event->getParam('exception')); + $this->assertInstanceOf('LmcRbac\Exception\UnauthorizedException', $event->getParam('exception')); } public function createRouteMatch(array $params = []) { + return new RouteMatch($params); + /* $class = class_exists(V2RouteMatch::class) ? V2RouteMatch::class : RouteMatch::class; return new $class($params); + */ } } diff --git a/tests/Guard/GuardPluginManagerTest.php b/tests/Guard/GuardPluginManagerTest.php index a3cfaae6..c6bd479a 100644 --- a/tests/Guard/GuardPluginManagerTest.php +++ b/tests/Guard/GuardPluginManagerTest.php @@ -90,7 +90,7 @@ public function testCanCreateDefaultGuards($type, $options) public function testThrowExceptionForInvalidPlugin() { - $this->expectException('LmcRbacMvc\Exception\RuntimeException'); + $this->expectException('LmcRbac\Exception\RuntimeException'); $pluginManager = new GuardPluginManager(new ServiceManager()); $pluginManager->get('stdClass'); diff --git a/tests/Guard/RouteGuardTest.php b/tests/Guard/RouteGuardTest.php index 418b5af3..1f5bd7f7 100644 --- a/tests/Guard/RouteGuardTest.php +++ b/tests/Guard/RouteGuardTest.php @@ -19,7 +19,7 @@ namespace LmcRbacMvcTest\Guard; use Laminas\Mvc\MvcEvent; -use Laminas\Mvc\Router\RouteMatch as V2RouteMatch; +//use Laminas\Mvc\Router\RouteMatch as V2RouteMatch; use Laminas\Router\RouteMatch; use LmcRbacMvc\Guard\ControllerGuard; use LmcRbacMvc\Guard\GuardInterface; @@ -466,12 +466,15 @@ public function testProperlySetUnauthorizedAndTriggerEventOnUnauthorization() $this->assertTrue($event->propagationIsStopped()); $this->assertEquals(RouteGuard::GUARD_UNAUTHORIZED, $event->getError()); - $this->assertInstanceOf('LmcRbacMvc\Exception\UnauthorizedException', $event->getParam('exception')); + $this->assertInstanceOf('LmcRbac\Exception\UnauthorizedException', $event->getParam('exception')); } public function createRouteMatch(array $params = []) { + return new RouteMatch($params); + /* $class = class_exists(V2RouteMatch::class) ? V2RouteMatch::class : RouteMatch::class; return new $class($params); + */ } } diff --git a/tests/Guard/RoutePermissionsGuardTest.php b/tests/Guard/RoutePermissionsGuardTest.php index d0d2e980..d8411c84 100644 --- a/tests/Guard/RoutePermissionsGuardTest.php +++ b/tests/Guard/RoutePermissionsGuardTest.php @@ -18,7 +18,7 @@ namespace LmcRbacMvcTest\Guard; use Laminas\Mvc\MvcEvent; -use Laminas\Mvc\Router\RouteMatch as V2RouteMatch; +//use Laminas\Mvc\Router\RouteMatch as V2RouteMatch; use Laminas\Router\RouteMatch; use LmcRbacMvc\Guard\ControllerGuard; use LmcRbacMvc\Guard\GuardInterface; @@ -461,7 +461,7 @@ public function testProperlySetUnauthorizedAndTriggerEventOnUnauthorization() $this->assertTrue($event->propagationIsStopped()); $this->assertEquals(RouteGuard::GUARD_UNAUTHORIZED, $event->getError()); - $this->assertInstanceOf('LmcRbacMvc\Exception\UnauthorizedException', $event->getParam('exception')); + $this->assertInstanceOf('LmcRbac\Exception\UnauthorizedException', $event->getParam('exception')); } public function createRouteMatch(array $params = []): RouteMatch diff --git a/tests/Options/ModuleOptionsTest.php b/tests/Options/ModuleOptionsTest.php index b6e2c45f..0e78058e 100644 --- a/tests/Options/ModuleOptionsTest.php +++ b/tests/Options/ModuleOptionsTest.php @@ -73,7 +73,7 @@ public function testSettersAndGetters() public function testThrowExceptionForInvalidProtectionPolicy() { - $this->expectException(\LmcRbacMvc\Exception\RuntimeException::class); + $this->expectException(\LmcRbac\Exception\RuntimeException::class); $moduleOptions = new ModuleOptions(); $moduleOptions->setProtectionPolicy('invalid'); @@ -81,7 +81,7 @@ public function testThrowExceptionForInvalidProtectionPolicy() public function testThrowExceptionIfMoreThanOneRoleProviderIsSet() { - $this->expectException(\LmcRbacMvc\Exception\RuntimeException::class); + $this->expectException(\LmcRbac\Exception\RuntimeException::class); $moduleOptions = new ModuleOptions(); $moduleOptions->setRoleProvider(['foo', 'bar']); diff --git a/tests/Role/InMemoryRoleProviderTest.php b/tests/Role/InMemoryRoleProviderTest.php index 1d3c8bd2..f79ea240 100644 --- a/tests/Role/InMemoryRoleProviderTest.php +++ b/tests/Role/InMemoryRoleProviderTest.php @@ -18,7 +18,6 @@ namespace LmcRbacMvcTest\Role; -use LmcRbacMvc\Exception\RoleNotFoundException; use LmcRbacMvc\Role\InMemoryRoleProvider; use PHPUnit\Framework\TestCase; diff --git a/tests/Role/ObjectRepositoryRoleProviderTest.php b/tests/Role/ObjectRepositoryRoleProviderTest.php index a9f43627..ce92168e 100644 --- a/tests/Role/ObjectRepositoryRoleProviderTest.php +++ b/tests/Role/ObjectRepositoryRoleProviderTest.php @@ -224,7 +224,7 @@ public function testThrowExceptionIfAskedRoleIsNotFound() $objectRepositoryRoleProvider = new ObjectRepositoryRoleProvider($objectRepository, 'name'); $this->expectException( - \LmcRbacMvc\Exception\RoleNotFoundException::class, + \LmcRbac\Exception\RoleNotFoundException::class, 'Some roles were asked but could not be loaded from database: guest, admin' ); diff --git a/tests/Role/RoleProviderPluginManagerTest.php b/tests/Role/RoleProviderPluginManagerTest.php index 413743da..f1b3d3ef 100644 --- a/tests/Role/RoleProviderPluginManagerTest.php +++ b/tests/Role/RoleProviderPluginManagerTest.php @@ -28,7 +28,7 @@ class RoleProviderPluginManagerTest extends \PHPUnit\Framework\TestCase { public function testValidationOfPluginFailsIfRoleProviderInterfaceIsNotImplemented() { - $this->expectException('LmcRbacMvc\Exception\RuntimeException'); + $this->expectException('LmcRbac\Exception\RuntimeException'); $pluginManager = new RoleProviderPluginManager(new ServiceManager()); $pluginManager->get('stdClass', []); diff --git a/tests/View/Strategy/RedirectStrategyTest.php b/tests/View/Strategy/RedirectStrategyTest.php index dc843c5f..b2ed5968 100644 --- a/tests/View/Strategy/RedirectStrategyTest.php +++ b/tests/View/Strategy/RedirectStrategyTest.php @@ -22,9 +22,9 @@ use Laminas\Http\Request as HttpRequest; use Laminas\Http\Response as HttpResponse; use Laminas\Mvc\MvcEvent; -use Laminas\Mvc\Router\Http\TreeRouteStack as V2TreeRouteStack; +//use Laminas\Mvc\Router\Http\TreeRouteStack as V2TreeRouteStack; use Laminas\Router\Http\TreeRouteStack; -use LmcRbacMvc\Exception\UnauthorizedException; +use LmcRbac\Exception\UnauthorizedException; use LmcRbacMvc\Options\RedirectStrategyOptions; use LmcRbacMvc\View\Strategy\RedirectStrategy; @@ -198,7 +198,10 @@ public function testCanAppendPreviousUri() public function createTreeRouteStack($routePluginManager = null) { + return new TreeRouteStack($routePluginManager); + /* $class = class_exists(V2TreeRouteStack::class) ? V2TreeRouteStack::class : TreeRouteStack::class; return new $class($routePluginManager); + */ } } diff --git a/tests/View/Strategy/UnauthorizedStrategyTest.php b/tests/View/Strategy/UnauthorizedStrategyTest.php index 888470b5..627a910b 100644 --- a/tests/View/Strategy/UnauthorizedStrategyTest.php +++ b/tests/View/Strategy/UnauthorizedStrategyTest.php @@ -21,7 +21,7 @@ use Laminas\Http\Response as HttpResponse; use Laminas\Mvc\MvcEvent; use Laminas\View\Model\ViewModel; -use LmcRbacMvc\Exception\UnauthorizedException; +use LmcRbac\Exception\UnauthorizedException; use LmcRbacMvc\Guard\GuardInterface; use LmcRbacMvc\Options\UnauthorizedStrategyOptions; use LmcRbacMvc\View\Strategy\UnauthorizedStrategy;