Exemplo n.º 1
0
 public function setUp()
 {
     Bootstrap::setUpAclDatabase();
     $em = Bootstrap::getServiceManager()->get('doctrine.entitymanager.orm_default');
     /* @var $em \Doctrine\ORM\EntityManager */
     $this->serviceManager = Bootstrap::getServiceManager();
     $this->acl = $this->serviceManager->get('jaztec_acl_service')->getAcl();
     $resource1 = new \JaztecAcl\Entity\Acl\Resource('resource01');
     $resource2 = new \JaztecAcl\Entity\Acl\Resource('resource02', $resource1);
     $resource3 = new \JaztecAcl\Entity\Acl\Resource('resource03', $resource2);
     $resource4 = new \JaztecAcl\Entity\Acl\Resource('resource04');
     $resource5 = new \JaztecAcl\Entity\Acl\Resource('resource05', $resource4);
     $privilege1 = new \JaztecAcl\Entity\Acl\Privilege();
     $privilege1->setResource($resource5);
     $privilege1->setRole($em->getRepository('JaztecAcl\\Entity\\Acl\\Role')->findOneBy(['name' => 'guest']));
     $privilege1->setType('allow');
     $em->persist($privilege1);
     $em->persist($resource1);
     $em->persist($resource2);
     $em->persist($resource3);
     $em->persist($resource4);
     $em->persist($resource5);
     $em->flush();
     // Clear the ACL.
     $this->acl->removeResourceAll();
     $this->acl->removeRoleAll();
     $this->acl->setupAcl();
 }
Exemplo n.º 2
0
 public function setUp()
 {
     Bootstrap::setUpAclDatabase();
     $this->serviceManager = Bootstrap::getServiceManager();
     $em = Bootstrap::getServiceManager()->get('doctrine.entitymanager.orm_default');
     /* @var $em \Doctrine\ORM\EntityManager */
     $aclService = $this->serviceManager->get('jaztec_acl_service');
     $aclService->setEntityManager($em);
     // Configure the ACL object needed by our AclService.
     $aclService->getAcl()->removeResourceAll();
     $aclService->getAcl()->removeRoleAll();
     $aclService->getAcl()->setupAcl();
     /* @var $aclService \JaztecAcl\Service\AclService */
     // Add a test resource to the ACL
     if (!$aclService->getAcl()->hasResource('resource01')) {
         $aclService->getAcl()->addResource('resource01');
     }
     $this->aclService = $aclService;
 }
 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);
 }
 public function setUp()
 {
     Bootstrap::setUpAclDatabase();
     $this->directObject = new \JaztecAcl\Direct\AuthorizedDirectObject();
     $this->directObject->setServiceLocator(Bootstrap::getServiceManager());
 }