FakeLdap.php in Lightweight Directory Access Protocol (LDAP) 8.4
File
ldap_servers/tests/modules/ldap_servers_dummy/src/FakeLdap.php
View source
<?php
declare (strict_types=1);
namespace Drupal\ldap_servers_dummy;
use Symfony\Component\Ldap\Adapter\EntryManagerInterface;
use Symfony\Component\Ldap\Exception\ConnectionException;
use Symfony\Component\Ldap\LdapInterface;
class FakeLdap implements LdapInterface {
protected $bindException = FALSE;
protected $queryResult;
protected $escapeResponse;
protected $entryManagerResponse;
public function bind(string $dn = NULL, string $password = NULL) : void {
if ($this->bindException) {
throw new ConnectionException('Failed connection');
}
}
public function query($dn, $query, array $options = []) {
$response = new FakeQuery();
$response
->setResult($this->queryResult[$query] ?? new FakeCollection([]));
return $response;
}
public function getEntryManager() : EntryManagerInterface {
return $this->entryManagerResponse;
}
public function escape($subject, $ignore = '', $flags = 0) : string {
return $this->escapeResponse;
}
public function setBindException(bool $bindException) : void {
$this->bindException = $bindException;
}
public function setQueryResult(array $queryResult) : void {
$this->queryResult = $queryResult;
}
public function setEscapeResponse(string $escapeResponse) : void {
$this->escapeResponse = $escapeResponse;
}
public function setEntryManagerResponse(EntryManagerInterface $entryManagerResponse) : void {
$this->entryManagerResponse = $entryManagerResponse;
}
}
Classes
Name |
Description |
FakeLdap |
Fake server to simulate querying with symfony/ldap. |