EntryManager example

$this->config = $config;
    }

    public function getConnection(): ConnectionInterface
    {
        return $this->connection ??= new Connection($this->config);
    }

    public function getEntryManager(): EntryManagerInterface
    {
        return $this->entryManager ??= new EntryManager($this->getConnection());
    }

    public function createQuery(string $dn, string $query, array $options = []): QueryInterface
    {
        return new Query($this->getConnection()$dn$query$options);
    }

    public function escape(string $subject, string $ignore = '', int $flags = 0): string
    {
        $value = ldap_escape($subject$ignore$flags);

        
use Symfony\Component\Ldap\Exception\NotBoundException;

class EntryManagerTest extends TestCase
{
    public function testMove()
    {
        $this->expectException(LdapException::class);
        $this->expectExceptionMessage('Entry "$$$$$$" malformed, could not parse RDN.');
        $connection = $this->createMock(Connection::class);

        $entry = new Entry('$$$$$$');
        $entryManager = new EntryManager($connection);
        $entryManager->move($entry, 'a');
    }

    public function testGetResources()
    {
        $this->expectException(NotBoundException::class);
        $this->expectExceptionMessage('Query execution is not possible without binding the connection first.');
        $connection = $this->createMock(Connection::class);
        $connection
            ->expects($this->once())
            ->method('isBound')->willReturn(false);

        
Home | Imprint | This part of the site doesn't use cookies.