You are here

protected function DrupalUserProcessorTests::setUp in Lightweight Directory Access Protocol (LDAP) 8.3

Test setup.

Overrides UnitTestCase::setUp

File

ldap_user/tests/src/Unit/DrupalUserProcessorTests.php, line 28

Class

DrupalUserProcessorTests
Tests for the DrupalUserProcessor.

Namespace

Drupal\Tests\ldap_user\Unit

Code

protected function setUp() {
  parent::setUp();
  $this->provisioningEvents = [
    self::PROVISION_TO_DRUPAL => [
      self::EVENT_SYNC_TO_DRUPAL_USER,
      self::EVENT_SYNC_TO_DRUPAL_USER,
    ],
    self::PROVISION_TO_LDAP => [
      self::EVENT_SYNC_TO_LDAP_ENTRY,
      self::EVENT_CREATE_LDAP_ENTRY,
    ],
  ];
  $this->config = $this
    ->getMockBuilder('\\Drupal\\Core\\Config\\ImmutableConfig')
    ->disableOriginalConstructor()
    ->getMock();
  $this->configFactory = $this
    ->getMockBuilder('\\Drupal\\Core\\Config\\ConfigFactory')
    ->disableOriginalConstructor()
    ->getMock();
  $this->configFactory
    ->expects($this
    ->any())
    ->method('get')
    ->with('ldap_user.settings')
    ->willReturn($this->config);
  $this->cacheFactory = $this
    ->getMockBuilder('\\Drupal\\Core\\Cache\\CacheFactory')
    ->disableOriginalConstructor()
    ->getMock();
  $this->cacheFactory
    ->expects($this
    ->any())
    ->method('get')
    ->willReturn(FALSE);
  $this->detailLog = $this
    ->getMockBuilder('\\Drupal\\ldap_servers\\Logger\\LdapDetailLog')
    ->disableOriginalConstructor()
    ->getMock();
  $this->container = new ContainerBuilder();
  $this->container
    ->set('config.factory', $this->configFactory);
  $this->container
    ->set('cache.default', $this->cacheFactory);
  $this->container
    ->set('ldap.detail_log', $this->detailLog);
  \Drupal::setContainer($this->container);
}