You are here

public function LdapAuthorizationOg2Tests::setUp in Lightweight Directory Access Protocol (LDAP) 7.2

Same name and namespace in other branches
  1. 8.2 ldap_authorization/tests/Og2Tests.test \LdapAuthorizationOg2Tests::setUp()
  2. 7 ldap_authorization/tests/Og/Og2.test \LdapAuthorizationOg2Tests::setUp()

Sets up a Drupal site for running functional and integration tests.

Generates a random database prefix and installs Drupal with the specified installation profile in DrupalWebTestCase::$profile into the prefixed database. Afterwards, installs any additional modules specified by the test.

After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.

Parameters

...: List of modules to enable for the duration of the test. This can be either a single array or a variable number of string arguments.

Overrides LdapTestCase::setUp

See also

DrupalWebTestCase::prepareDatabasePrefix()

DrupalWebTestCase::changeDatabasePrefix()

DrupalWebTestCase::prepareEnvironment()

File

ldap_authorization/tests/Og2Tests.test, line 58

Class

LdapAuthorizationOg2Tests
Simpletest for Ldap Authorization OG Module, for og 7.x-2.x.

Code

public function setUp($addl_modules = []) {
  parent::setUp([
    'ldap_authentication',
    'ldap_authorization',
    'ldap_authorization_og',
  ]);
  variable_set('ldap_simpletest', 2);
  $this->user1 = $this
    ->drupalCreateUser();
  $this->groups = [];
  $this
    ->prepTestData(LDAP_TEST_LDAP_NAME, [
    'activedirectory1',
  ]);

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

  // 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'];
    $settings = [];
    $settings['type'] = $this->groupBundle;
    $settings[OG_GROUP_FIELD][LANGUAGE_NONE][0]['value'] = 1;
    $settings['uid'] = $this->user1->uid;
    $settings['title'] = $label;
    $settings['type'] = 'group';
    $this->group_nodes[$label] = $this
      ->drupalCreateNode($settings);
  }
}