public function let(LdapConnectionInterface $connection) { $config = new Configuration(); $config->setCacheType('none'); $connection->execute(Argument::any())->willReturn($this->ldapEntries); $connection->getConfig()->willReturn(new DomainConfiguration('example.local')); $cache = CacheFactory::get($config->getCacheType(), $config->getCacheOptions()); $parser = SchemaParserFactory::get($config->getSchemaFormat(), $config->getSchemaFolder()); $dispatcher = new SymfonyEventDispatcher(); $schemaFactory = new LdapObjectSchemaFactory($cache, $parser, $dispatcher); $this->beConstructedWith($schemaFactory->get('ad', 'user'), $connection); }
function let(LdapConnectionInterface $connection) { $config = new Configuration(); $domain = new DomainConfiguration('example.com'); $domain->setServers(['example'])->setBaseDn('dc=example,dc=com')->setLazyBind(true)->setPageSize(500); $connection->getConfig()->willReturn($domain); $config->setCacheType('none'); $parser = SchemaParserFactory::get($config->getSchemaFormat(), $config->getSchemaFolder()); $cache = CacheFactory::get($config->getCacheType(), []); $dispatcher = new SymfonyEventDispatcher(); $schemaFactory = new LdapObjectSchemaFactory($cache, $parser, $dispatcher); $this->fb = new FilterBuilder(); $this->schema = $schemaFactory; $this->objectSchema = $schema = new LdapObjectSchema('ad', 'user'); $this->objectSchema->setFilter($this->fb->bAnd($this->fb->eq('objectCategory', 'person'), $this->fb->eq('objectClass', 'user'))); $this->beConstructedWith($connection, $schemaFactory); }
function it_should_sort_results_for_multiple_aliases($connection) { $config = new Configuration(); $domain = new DomainConfiguration('example.com'); $domain->setServers(['example'])->setBaseDn('dc=example,dc=com')->setLazyBind(true)->setPageSize(500); $connection->getConfig()->willReturn($domain); $config->setCacheType('none'); $parser = SchemaParserFactory::get($config->getSchemaFormat(), $config->getSchemaFolder()); $cache = CacheFactory::get($config->getCacheType(), []); $dispatcher = new SymfonyEventDispatcher(); $schemaFactory = new LdapObjectSchemaFactory($cache, $parser, $dispatcher); $ou = $schemaFactory->get('ad', 'ou'); $container = $schemaFactory->get('ad', 'container'); $filter = new OperatorCollection(); $filter->addLdapObjectSchema($ou); $filter->addLdapObjectSchema($container); $this->operation->setFilter($filter); $this->operation->setAttributes([]); $connection->execute(Argument::that(function ($op) { return $op->getFilter() == '(objectClass=organizationalUnit)'; }))->shouldBeCalled()->willReturn($this->ous); $connection->execute(Argument::that(function ($op) { return $op->getFilter() == '(&(objectCategory=container))'; }))->shouldBeCalled()->willReturn($this->containers); $this->setOrderBy(['Name' => LdapQuery::ORDER['ASC'], 'ou.Description' => LdapQuery::ORDER['DESC']]); $this->getResult()->shouldHavePlaceKeyAndValue(0, 'name', 'Computers'); $this->getResult()->shouldHavePlaceKeyAndValue(1, 'name', 'Employees'); $this->getResult()->shouldHavePlaceKeyAndValue(2, 'name', 'Users'); $this->getResult()->shouldHavePlaceKeyAndValue(3, 'name', 'West'); }