Exemplo n.º 1
0
 /**
  * @covers \BjyAuthorize\Guard\Route::__construct
  * @covers \BjyAuthorize\Guard\Route::getRules
  */
 public function testGetRulesWithAssertion()
 {
     $controller = new Route(array(array('route' => 'test/route', 'roles' => array('admin', 'user'), 'assertion' => 'test-assertion')), $this->serviceLocator);
     $rules = $controller->getRules();
     $this->assertCount(1, $rules['allow']);
     $this->assertContains(array(array('admin', 'user'), 'route/test/route', null, 'test-assertion'), $rules['allow']);
 }
Exemplo n.º 2
0
 /**
  * @covers \BjyAuthorize\Guard\Route::__construct
  * @covers \BjyAuthorize\Guard\Route::getResources
  * @covers \BjyAuthorize\Guard\Route::getRules
  */
 public function testGetResourcesGetRules()
 {
     $controller = new Route(array(array('route' => 'test/route', 'roles' => array('admin', 'user')), array('route' => 'test2-route', 'roles' => array('admin2', 'user2')), array('route' => 'test3-route', 'roles' => 'admin3')), $this->serviceLocator);
     $resources = $controller->getResources();
     $this->assertCount(3, $resources);
     $this->assertContains('route/test/route', $resources);
     $this->assertContains('route/test2-route', $resources);
     $this->assertContains('route/test3-route', $resources);
     $rules = $controller->getRules();
     $this->assertCount(3, $rules['allow']);
     $this->assertContains(array(array('admin', 'user'), 'route/test/route'), $rules['allow']);
     $this->assertContains(array(array('admin2', 'user2'), 'route/test2-route'), $rules['allow']);
     $this->assertContains(array(array('admin3'), 'route/test3-route'), $rules['allow']);
 }