You are here

public function SimpleLdapServerConnectionTestCase::testLdapServer in Simple LDAP 7

Same name and namespace in other branches
  1. 7.2 simple_ldap.test \SimpleLdapServerConnectionTestCase::testLdapServer()

Test the LDAP server configuration and connectivity.

File

./simple_ldap.test, line 64
Tests for Simple LDAP module.

Class

SimpleLdapServerConnectionTestCase

Code

public function testLdapServer() {

  // Initialize the LDAP server.
  $this->server = new SimpleLdapServer();

  // Initialize t() params.
  $t = array(
    ':host' => $this->server->host,
    ':port' => $this->server->port,
    ':tls' => $this->server->starttls ? ' ' . t('using startTLS') : '',
    ':ssl' => strpos($this->server->host, 'ldaps://') === 0 ? ' ' . t('using SSL') : '',
  );

  // Test connectivity to the configured LDAP server.
  $this
    ->assertTrue($this->server
    ->bind(), t('Successfully bound to :host on port :port:tls:ssl.', $t));
  $this
    ->assertTrue($this->server
    ->unbind(), t('Successfully unbound from :host.', $t));
}