private static function get_action_auth(ActionAuthorization $action, array $values)
 {
     $auth_array = array();
     foreach ($values as $role_htlm_id) {
         $role = substr($role_htlm_id, strlen($action->get_bit()) - 1);
         $auth_array[$role_htlm_id] = 1;
     }
     return $auth_array;
 }
 public function test_build_from_auth_array()
 {
     $action1 = new ActionAuthorization('toto', 1);
     $action2 = new ActionAuthorization('toto', 2);
     $settings = new AuthorizationsSettings(array($action1, $action2));
     $settings->build_from_auth_array(array('r1' => 3, 'r0' => 2, '1' => 2, '2' => 3, 'm4' => 1));
     self::assertEquals(array('r1' => 1, '2' => 1, 'm4' => 1), $action1->get_roles_auths()->build_auth_array());
     self::assertEquals(array('r1' => 1, 'r0' => 1, '1' => 1, '2' => 1), $action2->get_roles_auths()->build_auth_array());
 }
 private static function merge_auth_array(array &$global, ActionAuthorization $action)
 {
     foreach ($action->build_auth_array() as $role => $value) {
         if (!empty($global[$role])) {
             $global[$role] |= $value;
         } else {
             $global[$role] = $value;
         }
     }
 }
 public function test_build_from_auth_array()
 {
     $action = new ActionAuthorization('toto', 4);
     $action->build_from_auth_array(array('r1' => 4, 'r0' => 4, 'm1' => 4));
     self::assertEquals(new RolesAuthorizations(array('r1' => 1, 'r0' => 1, 'm1' => 1)), $action->get_roles_auths());
 }