HosipLan

Untitled

Oct 6th, 2011
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1. class RolePermissionTest extends Kdyby\Testing\OrmTestCase
  2. {
  3.  
  4.     public function testPersisting()
  5.     {
  6.         $action = new ACL\Action("read");
  7.         $resource = new ACL\Resource("article");
  8.         $privilege = new ACL\Privilege($resource, $action);
  9.  
  10.         $division = new ACL\Division("blog");
  11.         $division->addPrivilege($privilege);
  12.  
  13.         $role = new ACL\Role("reader", $division);
  14.         $role->createPermission($privilege);
  15.  
  16.         $this->getDao($division)->save($division);
  17.  
  18.         $this->assertEntityValues('Kdyby\Security\RBAC\Action', array('name' => 'read'), 1);
  19.         $this->assertEntityValues('Kdyby\Security\RBAC\Resource', array('name' => 'article'), 1);
  20.         $this->assertEntityValues('Kdyby\Security\RBAC\Privilege', array(
  21.                 'action' => 1,
  22.                 'resource' => 1
  23.             ), 1);
  24.  
  25.         $this->assertEntityValues('Kdyby\Security\RBAC\Division', array('name' => 'blog'), 1);
  26.         $this->assertEntityValues('Kdyby\Security\RBAC\Role', array(
  27.                 'name' => 'reader',
  28.                 'division' => 1
  29.             ), 1);
  30.  
  31.         $this->assertEntityValues('Kdyby\Security\RBAC\RolePermission', array(
  32.                 'isAllowed' => TRUE,
  33.                 'role' => 1,
  34.                 'privilege' => 1
  35.             ), 1);
  36.     }
  37.  
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment