class FakeBridge in Lightweight Directory Access Protocol (LDAP) 8.4
Fake LdapBridge to instantiate a fake server for testing.
Hierarchy
- class \Drupal\ldap_servers_dummy\FakeBridge implements LdapBridgeInterface
Expanded class hierarchy of FakeBridge
3 files declare their use of FakeBridge
- GroupManagerTest.php in ldap_servers/
tests/ src/ Kernel/ GroupManagerTest.php - LdapEntryProvisionTest.php in ldap_user/
tests/ src/ Kernel/ LdapEntryProvisionTest.php - LoginTest.php in ldap_authentication/
tests/ src/ Kernel/ LoginTest.php
File
- ldap_servers/
tests/ modules/ ldap_servers_dummy/ src/ FakeBridge.php, line 16
Namespace
Drupal\ldap_servers_dummyView source
class FakeBridge implements LdapBridgeInterface {
/**
* LDAP.
*
* @var \Drupal\ldap_servers_dummy\FakeLdap
*/
protected $ldap;
/**
* Logger.
*
* @var \Psr\Log\LoggerInterface
*/
protected $logger;
/**
* Entity Storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $entityManager;
/**
* Bind result.
*
* @var bool
*/
protected $bindResult = TRUE;
/**
* Constructor.
*
* @param \Psr\Log\LoggerInterface $logger
* Logger.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* Entity type manager.
*/
public function __construct(LoggerInterface $logger, EntityTypeManagerInterface $entity_type_manager) {
$this->logger = $logger;
$this->entityManager = $entity_type_manager
->getStorage('ldap_server');
}
/**
* {@inheritdoc}
*/
public function setServerById(string $sid) : void {
$server = $this->entityManager
->load($sid);
/** @var \Drupal\ldap_servers\Entity\Server $server */
if ($server) {
$this
->setServer($server);
}
}
/**
* {@inheritdoc}
*/
public function setServer(Server $server) : void {
if (!$this->ldap) {
$this->ldap = new FakeLdap();
}
}
/**
* {@inheritdoc}
*/
public function bind() : bool {
$this->ldap
->bind();
return $this->bindResult;
}
/**
* Set bind result.
*
* @param bool $bindResult
* Result.
*/
public function setBindResult(bool $bindResult) : void {
$this->bindResult = $bindResult;
}
/**
* {@inheritdoc}
*/
public function get() : LdapInterface {
return $this->ldap;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FakeBridge:: |
protected | property | Bind result. | |
FakeBridge:: |
protected | property | Entity Storage. | |
FakeBridge:: |
protected | property | LDAP. | |
FakeBridge:: |
protected | property | Logger. | |
FakeBridge:: |
public | function |
Bind (authenticate) against an active LDAP database. Overrides LdapBridgeInterface:: |
|
FakeBridge:: |
public | function |
Get LDAP service. Overrides LdapBridgeInterface:: |
|
FakeBridge:: |
public | function | Set bind result. | |
FakeBridge:: |
public | function |
Set Server. Overrides LdapBridgeInterface:: |
|
FakeBridge:: |
public | function |
Set Server by ID. Overrides LdapBridgeInterface:: |
|
FakeBridge:: |
public | function | Constructor. |