You are here

public function SimpleLdapUserManagerTest::testGetLdapUser in Simple LDAP 8

@covers ::getLdapUser

File

modules/simple_ldap_user/tests/src/Unit/SimpleLdapUserManagerTest.php, line 71
Contains \Drupal\Tests\simple_ldap\Unit\SimpleLdapUserManagerTest

Class

SimpleLdapUserManagerTest
@coversDefaultClass \Drupal\simple_ldap_user\SimpleLdapUserManager @group simple_ldap

Namespace

Drupal\Tests\simple_ldap\Unit

Code

public function testGetLdapUser() {
  $this
    ->setUpGetLdapUserTests();
  $this->server
    ->expects($this
    ->exactly(2))
    ->method('search')
    ->will($this
    ->onConsecutiveCalls(array(
    'dn="johnsmith"' => array(
      'cn' => array(
        'johnsmith',
      ),
      'mail' => array(
        'john@example.com',
      ),
    ),
    'dn="johnAsmith"' => array(
      'cn' => array(
        'johnAsmith',
      ),
      'mail' => array(
        'johnA@example.com',
      ),
    ),
  ), array(
    'dn="johnsmith"' => array(
      'cn' => array(
        'johnsmith',
      ),
      'mail' => array(
        'john@example.com',
      ),
    ),
  )));
  $user_manager = new SimpleLdapUserManager($this->server, $this->config_factory, $this->query_factory, $this->entity_manager);
  $user = $user_manager
    ->getLdapUser('johnsmith');
  $this
    ->assertInstanceOf(SimpleLdapUser::class, $user);
  return $user;
}