Ejemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     $this->serviceManager = Bootstrap::getServiceManager();
     $this->program = new Program();
     $this->program->setId(1);
     $this->program->setProgram('This is the program');
     $this->authorizeService = $this->serviceManager->get('BjyAuthorize\\Service\\Authorize');
     if (!$this->authorizeService->getAcl()->hasResource($this->program)) {
         $this->authorizeService->getAcl()->addResource($this->program);
         $this->authorizeService->getAcl()->allow([], $this->program, []);
     }
     /**
      * Add the resource on the fly
      */
     if (!$this->authorizeService->getAcl()->hasResource(new Program())) {
         $this->authorizeService->getAcl()->addResource(new Program());
     }
     $this->authorizeService->getAcl()->allow([], new Program(), []);
     $this->programLink = $this->serviceManager->get('viewhelpermanager')->get('programlink');
     $routeMatch = new RouteMatch(['program' => 1]);
     $routeMatch->setMatchedRouteName('route-program_entity_program');
     $this->programLink->setRouteMatch($routeMatch);
     /**
      * Bootstrap the application to have the other information available
      */
     $application = $this->serviceManager->get('application');
     $application->bootstrap();
 }
Ejemplo n.º 2
0
 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     $this->serviceManager = Bootstrap::getServiceManager();
     $this->call = new Call();
     $this->call->setId(1);
     $this->call->setCall('This is the call');
     $program = new Program();
     $program->setProgram('This is the program');
     $this->call->setProgram($program);
     $this->authorizeService = $this->serviceManager->get('BjyAuthorize\\Service\\Authorize');
     if (!$this->authorizeService->getAcl()->hasResource($this->call)) {
         $this->authorizeService->getAcl()->addResource($this->call);
         $this->authorizeService->getAcl()->allow([], $this->call, []);
     }
     /**
      * Add the resource on the fly
      */
     if (!$this->authorizeService->getAcl()->hasResource(new Call())) {
         $this->authorizeService->getAcl()->addResource(new Call());
     }
     $this->authorizeService->getAcl()->allow([], new Call(), []);
     $this->callLink = $this->serviceManager->get('viewhelpermanager')->get('calllink');
     /**
      * Bootstrap the application to have the other information available
      */
     $application = $this->serviceManager->get('application');
     $application->bootstrap();
 }
Ejemplo n.º 3
0
 /**
  * @covers \BjyAuthorize\Service\Authorize::load
  */
 public function testLoadLoadsAclFromCacheAndDoesNotBuildANewAclObject()
 {
     $acl = $this->getMock('Zend\\Permissions\\Acl\\Acl');
     $cache = $this->getMockBuilder('Zend\\Cache\\Storage\\Adapter\\Filesystem')->disableOriginalConstructor()->getMock();
     $cache->expects($this->once())->method('getItem')->will($this->returnCallback(function ($key, &$success) use($acl) {
         $success = true;
         return $acl;
     }));
     $serviceManager = new ServiceManager();
     $serviceManager->setService('BjyAuthorize\\Provider\\Identity\\ProviderInterface', $this->getMock('BjyAuthorize\\Provider\\Identity\\ProviderInterface'));
     $serviceManager->setService('BjyAuthorize\\Cache', $cache);
     $authorize = new Authorize(array('cache_key' => 'bjyauthorize-acl'), $serviceManager);
     $authorize->load();
     $this->assertSame($acl, $authorize->getAcl());
 }
Ejemplo n.º 4
0
 public function testGetAccessDenied()
 {
     $this->authorizeService->getAcl()->deny([], $this->doa, []);
     $this->assertNotContains('<a href', $this->doaLink->__invoke($this->doa, 'view-community'));
     $this->authorizeService->getAcl()->allow([], $this->doa, []);
 }
Ejemplo n.º 5
0
 /**
  * @group bjyoungblood/BjyAuthorize#258
  */
 public function testCanAddTraversableRoleToLoadRole()
 {
     $serviceLocator = $this->serviceLocator;
     $serviceLocator->setAllowOverride(true);
     $roleProviderMock = $this->getMockBuilder('BjyAuthorize\\Provider\\Role\\Config')->disableOriginalConstructor()->getMock();
     $roleProviderMock->expects($this->once())->method('getRoles')->will($this->returnValue(new \Zend\Stdlib\ArrayObject(array(new \BjyAuthorize\Acl\Role('test')))));
     $serviceLocator->setService('BjyAuthorize\\Provider\\Role\\Config', $roleProviderMock);
     $roleMock = $this->getMockBuilder('BjyAuthorize\\Service\\RoleProvidersServiceFactory')->disableOriginalConstructor()->getMock();
     $roleMock->expects($this->any())->method('createService')->will($this->returnValue(array($roleProviderMock)));
     $serviceLocator->setFactory('BjyAuthorize\\RoleProviders', $roleMock);
     $authorize = new Authorize(array('cache_key' => 'acl'), $this->serviceLocator);
     $authorize->load();
     $acl = $authorize->getAcl();
     $this->assertTrue($acl->hasRole('test'));
 }