'foo' ] ], [ 'LmcRbacMvc\Guard\RoutePermissionsGuard', [ 'post/delete' => 'post.delete' ] ], [ 'LmcRbacMvc\Guard\ControllerGuard', [ [ 'controller' => 'Foo', 'actions' => 'bar', 'roles' => 'baz' ] ] ], [ 'LmcRbacMvc\Guard\ControllerPermissionsGuard', [ [ 'controller' => 'Foo', 'actions' => 'bar', 'permissions' => 'baz' ] ] ], ]; } /** * @dataProvider guardProvider */ public function testCanCreateDefaultGuards($type, $options) { $serviceManager = new ServiceManager(); $serviceManager->setService('LmcRbacMvc\Options\ModuleOptions', new ModuleOptions()); $serviceManager->setService( 'LmcRbacMvc\Service\RoleService', $this->createMock('LmcRbacMvc\Service\RoleService') ); $serviceManager->setService( 'LmcRbacMvc\Service\AuthorizationService', $this->createMock('LmcRbacMvc\Service\AuthorizationService') ); $pluginManager = new GuardPluginManager($serviceManager); $guard = $pluginManager->get($type, $options); $this->assertInstanceOf($type, $guard); } public function testThrowExceptionForInvalidPlugin() { $this->expectException('LmcRbacMvc\Exception\RuntimeException'); $pluginManager = new GuardPluginManager(new ServiceManager()); $pluginManager->get('stdClass'); } }