You are here

public function LdapEntryProvisionTest::setUp in Lightweight Directory Access Protocol (LDAP) 8.4

Test setup.

Overrides KernelTestBase::setUp

File

ldap_user/tests/src/Kernel/LdapEntryProvisionTest.php, line 62

Class

LdapEntryProvisionTest
@coversDefaultClass \Drupal\ldap_servers\Processor\TokenProcessor @group ldap

Namespace

Drupal\Tests\ldap_user\Kernel

Code

public function setUp() : void {
  parent::setUp();
  $this
    ->installSchema('system', 'sequences');
  $this
    ->installEntitySchema('user');
  $this
    ->installSchema('externalauth', 'authmap');
  $server = Server::create([
    'id' => 'test',
    'timeout' => 30,
    'encryption' => 'none',
    'address' => 'example',
    'port' => 963,
    'basedn' => [],
  ]);
  $server
    ->save();
  $this
    ->config('ldap_user.settings')
    ->set('ldapEntryProvisionTriggers', [
    LdapUserAttributesInterface::PROVISION_LDAP_ENTRY_ON_USER_ON_USER_AUTHENTICATION,
  ])
    ->set('ldapEntryProvisionServer', $server
    ->id())
    ->set('ldapUserSyncMappings', [
    LdapUserAttributesInterface::PROVISION_TO_LDAP => [
      'dn' => [
        'ldap_attr' => '[dn]',
        'user_attr' => 'cn=[property.name],ou=people,dc=hogwarts,dc=edu',
        'convert' => FALSE,
        'user_tokens' => '',
        'config_module' => 'ldap_user',
        'prov_module' => 'ldap_user',
        'prov_events' => [
          'create_ldap_entry',
        ],
      ],
      'mail' => [
        'ldap_attr' => '[mail]',
        'user_attr' => '[property.mail]',
        'convert' => FALSE,
        'user_tokens' => '',
        'config_module' => 'ldap_user',
        'prov_module' => 'ldap_user',
        'prov_events' => [
          'create_ldap_entry',
        ],
      ],
    ],
  ])
    ->save();
  $fake_bridge = new FakeBridge($this->container
    ->get('logger.channel.ldap_user'), $this->container
    ->get('entity_type.manager'));
  $fake_bridge
    ->setServer($server);
  $this->container
    ->set('ldap.bridge', $fake_bridge);
  $this->subscriber = new LdapEntryProvisionSubscriber($this->container
    ->get('config.factory'), $this->container
    ->get('logger.channel.ldap_user'), $this->container
    ->get('ldap.detail_log'), $this->container
    ->get('entity_type.manager'), $this->container
    ->get('module_handler'), $this->container
    ->get('ldap.user_manager'), $this->container
    ->get('ldap_user.field_provider'), $this->container
    ->get('file_system'));
}