class FakeLdap in Lightweight Directory Access Protocol (LDAP) 8.4
Fake server to simulate querying with symfony/ldap.
Can be used in tests, requires overloading the LdapBridge class.
Hierarchy
- class \Drupal\ldap_servers_dummy\FakeLdap implements \Symfony\Component\Ldap\LdapInterface
Expanded class hierarchy of FakeLdap
File
- ldap_servers/
tests/ modules/ ldap_servers_dummy/ src/ FakeLdap.php, line 16
Namespace
Drupal\ldap_servers_dummyView source
class FakeLdap implements LdapInterface {
/**
* Let binding fail.
*
* @var bool
*/
protected $bindException = FALSE;
/**
* List of query responses keyed by query.
*
* @var array
*/
protected $queryResult;
/**
* Escape response.
*
* @var string
*/
protected $escapeResponse;
/**
* Entry Manager.
*
* @var \Symfony\Component\Ldap\Adapter\EntryManagerInterface
*/
protected $entryManagerResponse;
/**
* {@inheritdoc}
*/
public function bind(string $dn = NULL, string $password = NULL) : void {
if ($this->bindException) {
throw new ConnectionException('Failed connection');
}
}
/**
* {@inheritdoc}
*/
public function query($dn, $query, array $options = []) {
$response = new FakeQuery();
$response
->setResult($this->queryResult[$query] ?? new FakeCollection([]));
return $response;
}
/**
* {@inheritdoc}
*/
public function getEntryManager() : EntryManagerInterface {
return $this->entryManagerResponse;
}
/**
* {@inheritdoc}
*/
public function escape($subject, $ignore = '', $flags = 0) : string {
return $this->escapeResponse;
}
/**
* Set bind exception.
*
* @param bool $bindException
* Bind exception.
*/
public function setBindException(bool $bindException) : void {
$this->bindException = $bindException;
}
/**
* Set the query result.
*
* @param array $queryResult
* Query result.
*/
public function setQueryResult(array $queryResult) : void {
$this->queryResult = $queryResult;
}
/**
* Set the escape response.
*
* @param string $escapeResponse
* Response.
*/
public function setEscapeResponse(string $escapeResponse) : void {
$this->escapeResponse = $escapeResponse;
}
/**
* Set the entry manager response.
*
* @param \Symfony\Component\Ldap\Adapter\EntryManagerInterface $entryManagerResponse
* Entry Manager.
*/
public function setEntryManagerResponse(EntryManagerInterface $entryManagerResponse) : void {
$this->entryManagerResponse = $entryManagerResponse;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FakeLdap:: |
protected | property | Let binding fail. | |
FakeLdap:: |
protected | property | Entry Manager. | |
FakeLdap:: |
protected | property | Escape response. | |
FakeLdap:: |
protected | property | List of query responses keyed by query. | |
FakeLdap:: |
public | function | ||
FakeLdap:: |
public | function | ||
FakeLdap:: |
public | function | ||
FakeLdap:: |
public | function | ||
FakeLdap:: |
public | function | Set bind exception. | |
FakeLdap:: |
public | function | Set the entry manager response. | |
FakeLdap:: |
public | function | Set the escape response. | |
FakeLdap:: |
public | function | Set the query result. |