You are here

public function LdapAuthorizationOg2Tests::getTestData in Lightweight Directory Access Protocol (LDAP) 8.2

Same name and namespace in other branches
  1. 7.2 ldap_authorization/tests/Og2Tests.test \LdapAuthorizationOg2Tests::getTestData()

get test data in convenient format, so tests are easier to read and write

2 calls to LdapAuthorizationOg2Tests::getTestData()
LdapAuthorizationOg2Tests::testBasicFunctionsAndApi in ldap_authorization/tests/Og2Tests.test
just make sure install succeeds and
LdapAuthorizationOg2Tests::testFlags in ldap_authorization/tests/Og2Tests.test
authorization configuration flags tests clumped together

File

ldap_authorization/tests/Og2Tests.test, line 101

Class

LdapAuthorizationOg2Tests

Code

public function getTestData($debug = FALSE) {
  $group_nodes = array();
  $group_nids = array();
  $group_entity_ids = array();
  $roles = array();
  $roles_by_name = array();
  $consumer_ids = array();
  foreach (array(
    'gryffindor',
    'students',
    'faculty',
    'users',
    'hufflepuff',
    'slytherin',
  ) as $i => $group_name) {
    list($group_nodes[$group_name], $group_entity_ids[$group_name]) = ldap_authorization_og2_get_group_from_name($this->groupEntityType, $group_name);
    $nid = $group_nodes[$group_name]->nid;
    $group_nids[$group_name] = $nid;
    $roles[$group_name] = og_roles($this->groupEntityType, $this->groupBundle, $nid, FALSE, TRUE);
    $roles_by_name[$group_name] = array_flip($roles[$group_name]);
    foreach ($roles[$group_name] as $rid => $role_name) {
      $consumer_ids[$group_name][$role_name] = ldap_authorization_og_authorization_id($nid, $rid, 'node');
      $consumer_ids[$group_name][$rid] = ldap_authorization_og_authorization_id($nid, $rid, 'node');
    }
  }
  if ($debug) {
    debug("group_nids");
    debug($group_nids);
    debug("group_entity_ids");
    debug($group_entity_ids);
    debug("roles");
    debug($roles);
    debug("roles_by_name");
    debug($roles_by_name);
  }
  return array(
    $group_nodes,
    $group_nids,
    $group_entity_ids,
    $roles_by_name,
    $consumer_ids,
  );
}