Ejemplo n.º 1
0
 public function testNodeWithNonStrictMode()
 {
     Fixtures::save('db');
     extract($this->_models);
     $result = Set::extract(Aco::node('root/printers/refill/unexisting', false), '/id');
     $expected = ['9', '6', '1'];
     $this->assertEqual($expected, $result);
 }
Ejemplo n.º 2
0
 /**
  * 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));
 }