You are here

public function SimpleLdapServerTest::testBindProvided in Simple LDAP 8

Test when credentials are provided in the bind() call.

@covers ::bind @depends testConnect

File

tests/src/Unit/SimpleLdapServerTest.php, line 95
Contains \Drupal\Tests\simple_ldap\Unit\SimpleLdapServer

Class

SimpleLdapServerTest
@coversDefaultClass \Drupal\simple_ldap\SimpleLdapServer @group simple_ldap

Namespace

Drupal\Tests\simple_ldap\Unit

Code

public function testBindProvided() {
  $this->ldap
    ->expects($this
    ->exactly(2))
    ->method('isBound')
    ->will($this
    ->onConsecutiveCalls(FALSE, TRUE));
  $this->ldap
    ->expects($this
    ->once())
    ->method('ldapBind')
    ->with('testdn', 'testpw')
    ->willReturn(TRUE);
  $server = new SimpleLdapServer($this->config_factory, $this->ldap);
  $server
    ->connect();
  $this
    ->assertTrue($server
    ->bind('testdn', 'testpw'));
}