You are here

function LdapAuthorizationOg1Tests::setUp in Lightweight Directory Access Protocol (LDAP) 8.2

Overrides LdapTestCase::setUp

File

ldap_authorization/tests/Og1Tests.test, line 48

Class

LdapAuthorizationOg1Tests

Code

function setUp($addl_modules = array()) {
  parent::setUp(array(
    'entity',
    'ctools',
    'og',
    'ldap_authentication',
    'ldap_authorization',
    'ldap_authorization_drupal_role',
    'ldap_authorization_og',
    'ldap_test',
    'og_ui',
  ));
  variable_set('ldap_simpletest', 2);
  if (ldap_authorization_og_og_version() != 1) {
    debug('LdapAuthorizationOg1Tests must be run with OG 7.x-1.x');
    return;
  }
  $this->user1 = $this
    ->drupalCreateUser();
  $this->groups = array();
  $this
    ->prepTestData(LDAP_TEST_LDAP_NAME, array(
    'activedirectory1',
  ));

  /**
   * Group:  The entity instance that will have members and content associated with it.
   * Group Entity: entity type: node, bundle: group, name: OG Group
   * Group Instances: $this->group_nodes[$label]
   *
   */

  // Create group and group content node types.
  $this->groupBundle = $this
    ->drupalCreateContentType(array(
    'type' => 'group',
    'name' => 'OG Group',
  ))->type;
  og_create_field(OG_GROUP_FIELD, $this->groupEntityType, $this->groupBundle);

  // entity type = "node" and group bundle = "group"
  og_create_field(OG_AUDIENCE_FIELD, $this->groupEntityType, $this->groupBundle);
  $this
    ->createCustomRoles();

  // create og group for each group in group csv
  $this->testFunctions
    ->populateFakeLdapServerData(LDAP_TEST_LDAP_NAME, 'activedirectory1');
  $this->testFunctions
    ->getCsvLdapData(LDAP_TEST_LDAP_NAME);
  foreach ($this->testFunctions->csvTables['groups'] as $guid => $group) {
    $label = $group['cn'];

    // $group_type_obj = $this->drupalCreateContentType(array('name' => $label, 'type' => $label));
    // og_create_field(OG_GROUP_FIELD, 'node', $group_type_obj->type);
    $settings = array();
    $settings['title'] = $label;
    $settings['type'] = $this->groupBundle;
    $settings[OG_GROUP_FIELD][LANGUAGE_NONE][0]['value'] = 1;
    $group_node = $this
      ->drupalCreateNode($settings);
    $group = og_get_group('node', $group_node->nid);
    $this->group_nodes[$label] = $group_node;
  }
}