You are here

function LdapServerTest::__construct in Lightweight Directory Access Protocol (LDAP) 7

Same name and namespace in other branches
  1. 8.2 ldap_test/LdapServerTest.class.php \LdapServerTest::__construct()
  2. 7.2 ldap_test/LdapServerTest.class.php \LdapServerTest::__construct()

Constructor Method

can take array of form property_name => property_value or $sid, where sid is used to derive the include file.

Overrides LdapServer::__construct

File

ldap_servers/tests/LdapServerTest.class.php, line 37
Simpletest ldapServer class for testing without an actual ldap server

Class

LdapServerTest

Code

function __construct($sid) {
  if (!is_scalar($sid)) {
    $test_data = $sid;
  }
  else {
    $test_data = variable_get('ldap_test_server__' . $sid, array());
  }
  $this->sid = $sid;
  $this->methodResponses = $test_data['methodResponses'];
  $this->testUsers = $test_data['users'];
  $this->testGroups = is_array($test_data) && isset($test_data['groups']) ? $test_data['groups'] : array();
  $this->searchResults = isset($test_data['search_results']) ? $test_data['search_results'] : array();
  $this->detailedWatchdogLog = variable_get('ldap_help_watchdog_detail', 0);
  foreach ($test_data['properties'] as $property_name => $property_value) {
    $this->{$property_name} = $property_value;
  }
  if (is_scalar($this->basedn)) {
    $this->basedn = unserialize($this->basedn);
  }
  if (isset($server_record['bindpw']) && $server_record['bindpw'] != '') {
    $this->bindpw = ldap_servers_decrypt($this->bindpw);
  }
}