You are here

public function SimpleLdapUserManagerTest::testLoadDrupalUser in Simple LDAP 8

@covers ::loadDrupalUser @depends testGetLdapUser

File

modules/simple_ldap_user/tests/src/Unit/SimpleLdapUserManagerTest.php, line 109
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 testLoadDrupalUser(SimpleLdapUser $ldap_user) {
  $attributes = $ldap_user
    ->getAttributes();
  $this
    ->setUpDrupalUserTests();
  $query = $this
    ->getMockBuilder('\\Drupal\\Core\\Entity\\Query\\QueryInterface')
    ->disableOriginalConstructor()
    ->getMock();
  $query
    ->expects($this
    ->exactly(2))
    ->method('condition')
    ->willReturn($query);
  $query
    ->expects($this
    ->once())
    ->method('execute')
    ->willReturn(array(
    5 => 5,
  ));
  $this->query_factory
    ->expects($this
    ->once())
    ->method('get')
    ->willReturn($query);
  $user_storage = $this
    ->getMockBuilder('\\Drupal\\user\\UserStorage')
    ->disableOriginalConstructor()
    ->getMock();
  $user_storage
    ->expects($this
    ->once())
    ->method('load')
    ->with(5)
    ->willReturn(TRUE);
  $this->entity_manager
    ->expects($this
    ->once())
    ->method('getStorage')
    ->with('user')
    ->willReturn($user_storage);
  $user_manager = new SimpleLdapUserManager($this->server, $this->config_factory, $this->query_factory, $this->entity_manager);
  $user = $user_manager
    ->loadDrupalUser($ldap_user);
  $this
    ->assertTrue(TRUE);
}