protected function SimpleLdapUserTest::setUp in Simple LDAP 8
Overrides BrowserTestBase::setUp
File
- modules/
simple_ldap_user/ tests/ src/ Functional/ SimpleLdapUserTest.php, line 28
Class
- SimpleLdapUserTest
- Tests Simple LDAP User login.
Namespace
Drupal\Tests\simple_ldap_user\FunctionalCode
protected function setUp() {
if (!extension_loaded('ldap')) {
$this
->markTestSkipped("Skipping because the PHP LDAP extension is not enabled.");
}
parent::setUp();
if (!extension_loaded('ldap')) {
$this
->markTestSkipped("Skipping because the PHP LDAP extension is not enabled.");
}
// These test work by connecting to a free online LDAP test server. See:
// http://www.forumsys.com/en/tutorials/integration-how-to/ldap/online-ldap-test-server/
// Configure the server settings.
$server_config = \Drupal::configFactory()
->getEditable('simple_ldap.server');
$server_config
->set('host', 'ldap.forumsys.com')
->set('port', 389)
->set('encryption', 'none')
->set('readonly', TRUE)
->set('binddn', 'cn=read-only-admin,dc=example,dc=com')
->set('bindpw', 'password')
->save();
// Configure the user settings.
$user_config = \Drupal::configFactory()
->getEditable('simple_ldap.user');
$user_config
->set('basedn', 'dc=example,dc=com')
->set('user_scope', 'sub')
->set('object_class.inetorgperson', 'inetorgperson')
->set('object_class.organizationalperson', 'organizationalperson')
->set('object_class.person', 'person')
->set('object_class.top', 'top')
->set('name_attribute', 'uid')
->set('mail_attribute', 'mail')
->save();
}