コード例 #1
0
ファイル: AclNodeTest.php プロジェクト: jails/li3_access
 public function testNodeEntity()
 {
     Fixtures::save('db');
     extract($this->_models);
     $user = $_user::create();
     $user->id = 1;
     $result = Set::extract(Aro::node($user), '/id');
     $expected = ['5', '2', '1'];
     $this->assertEqual($expected, $result);
     $group = $_group::create();
     $group->id = 1;
     $result = Set::extract(Aro::node($group), '/id');
     $expected = ['2', '1'];
     $this->assertEqual($expected, $result);
 }
コード例 #2
0
ファイル: PermissionTest.php プロジェクト: jails/li3_access
 /**
  * debug function - to help editing/creating test cases for the ACL component
  *
  * To check the overall ACL status at any time call $this->__debug();
  * Generates a list of the current aro and aco structures and a grid dump of the permissions that are defined
  * Only designed to work with the db based ACL
  *
  * @param bool $treesToo
  * @return void
  */
 protected function _debug($printTreesToo = false)
 {
     Aro::meta('title', 'alias');
     Aco::meta('title', 'alias');
     $aros = Aro::find('list', ['order' => 'lft']);
     $acos = Aco::find('list', ['order' => 'lft']);
     $rights = [$this->_privileges, 'create', 'read', 'update', 'delete'];
     $permissions['Aros v Acos >'] = $acos;
     foreach ($aros as $aro) {
         $row = [];
         foreach ($acos as $aco) {
             $perms = '';
             foreach ($rights as $right) {
                 if (Permission::check($aro, $aco, $right)) {
                     if ($right == $this->_privileges) {
                         $perms .= '****';
                         break;
                     }
                     $perms .= $right[0];
                 } elseif ($right != $this->_privileges) {
                     $perms .= ' ';
                 }
             }
             $row[] = $perms;
         }
         $permissions[$aro] = $row;
     }
     foreach ($permissions as $key => $values) {
         array_unshift($values, $key);
         $values = array_map([&$this, '_pad'], $values);
         $permissions[$key] = implode(' ', $values);
     }
     $permissions = array_map([&$this, '_pad'], $permissions);
     array_unshift($permissions, 'Current Permissions :');
     print_r(implode("\r\n", $permissions));
 }