protected function setUp() { Bootstrap::setUpAclDatabase(); // Gather variables $serviceManager = Bootstrap::getServiceManager(); $this->controller = new AuthorizedController(); $this->request = new Request(); $this->routeMatch = new RouteMatch(array()); $this->event = new MvcEvent(); $config = $serviceManager->get('Config'); $routerConfig = isset($config['router']) ? $config['router'] : array(); $router = HttpRouter::factory($routerConfig); // Setup the actual testcase. $this->event->setRouter($router); $this->event->setRouteMatch($this->routeMatch); $this->controller->setEvent($this->event); $this->controller->setServiceLocator($serviceManager); // Arranging the zfc-user services. $authMock = $this->getMock('ZfcUser\\Controller\\Plugin\\ZfcUserAuthentication'); $this->controller->getPluginManager()->setService('zfcUserAuthentication', $authMock); }
/** * @covers \JaztecAcl\Service\AclService::isAllowed */ public function testServicePrivilegeRequestCreation() { // Prepare the ACL $this->aclService->getAcl()->deny(); $this->aclService->getAcl()->allow('additionalRole'); // File a new request so it can be registered. $this->aclService->isAllowed('additionalRole', 'resource50', 'index'); $em = Bootstrap::getServiceManager()->get('doctrine.entitymanager.orm_default'); /* @var $em \Doctrine\ORM\EntityManager */ $requests = $em->getRepository('JaztecAcl\\Entity\\Monitor\\RequestedPrivilege')->findBy(array('privilege' => 'index', 'resource' => 'resource50')); /* @var $requests array */ $this->assertGreaterThan(0, count($requests), "The newly added privilege should exist in the database"); }
public function testCreatePrivilegeRequest() { // Set up the ACL $this->acl->allow(); $em = Bootstrap::getServiceManager()->get('doctrine.entitymanager.orm_default'); /* @var $em \Doctrine\ORM\EntityManager */ $this->acl->checkPrivilegeRequest('index', 'resource01', $em); $requests = $em->getRepository('JaztecAcl\\Entity\\Monitor\\RequestedPrivilege')->findBy(array('privilege' => 'index', 'resource' => 'resource01')); /* @var $requests array */ $this->assertGreaterThan(0, count($requests), "The newly added privilege should exist in the database"); $this->assertEquals(1, count($requests), "At least 1 occurance of this requested privilege should occur in the database"); $this->acl->checkPrivilegeRequest('index', 'resource01', $em); $requestsNewRun = $em->getRepository('JaztecAcl\\Entity\\Monitor\\RequestedPrivilege')->findBy(array('privilege' => 'index', 'resource' => 'resource01')); /* @var $requestsNewRun array */ $this->assertGreaterThan(0, count($requestsNewRun), "The newly added privilege should exist in the database, also in the second run"); $this->assertEquals(1, count($requestsNewRun), "After a second run their thould only be one instance of the requested privilege"); }
public function setUp() { Bootstrap::setUpAclDatabase(); $this->directObject = new \JaztecAcl\Direct\AuthorizedDirectObject(); $this->directObject->setServiceLocator(Bootstrap::getServiceManager()); }
$tool->dropSchema($classes); $tool->createSchema($classes); // Get the setup from the configuration. /* @var array $config */ $config = static::getServiceManager()->get('Config'); /* @var array $setUp */ $setUp = $config['TestSuite']['setUp']; // SetUp roles. /* $var array $roleSetIp */ $roleSetUp = $setUp['roles']; /* $var \JaztecAcl\Entity\Acl\Role[] $roles */ $roles = array(); foreach ($roleSetUp as $setUpConfig) { $role = new \JaztecAcl\Entity\Acl\Role($setUpConfig['name']); $role->setSort($setUpConfig['sort']); if (array_key_exists('parent', $setUpConfig)) { foreach ($roles as $cached) { /* @var \JaztecAcl\Entity\Acl\Role $cached */ if ($cached->getName() == $setUpConfig['parent']) { $role->setParent($cached); } } } $em->persist($role); $roles[] = $role; } $em->flush(); } } Bootstrap::init();