Author: Chad Sikorra (Chad.Sikorra@gmail.com)
Inheritance: implements IteratorAggregate
コード例 #1
0
 /**
  * Convert the batch values to LDAP batch mod specifications array.
  *
  * @return OperatorCollection
  */
 public function toLdap()
 {
     /** @var LdapObjectSchema $schema */
     foreach ($this->operators->getAliases() as $alias => $schema) {
         $this->schema = $schema;
         $this->processOperator($schema->getFilter(), null);
         foreach ($this->operators as $operator) {
             $this->processOperator($operator, $alias);
         }
     }
     return $this->operators;
 }
コード例 #2
0
 function it_should_clone_the_operator_collection()
 {
     $operator = new Comparison('foo', Comparison::EQ, 'bar');
     $operators = new OperatorCollection();
     $operators->add($operator);
     $operation = new QueryOperation($operators);
     $new = clone $operation;
     $operator->setAttribute('foobar');
     $this->setFilter($new->getFilter());
     $this->getFilter()->toLdapFilter()->shouldNotBeEqualTo('(foobar=bar)');
 }
コード例 #3
0
 function it_should_clone_the_operator_objects_when_cloning_the_collection()
 {
     $operator = new Comparison('foo', Comparison::EQ, 'bar');
     $operators = new OperatorCollection();
     $operators->add($operator);
     $new = clone $operators;
     $operator->setAttribute('foobar');
     $this->add(...$new->getComparisonOperators());
     $this->getComparisonOperators()->shouldNotBeLike([$operator]);
 }
コード例 #4
0
 function it_should_properly_convert_values_when_using_a_multivalued_converter()
 {
     $this->collection->add($this->filter->contains('user.logonWorkstations', ['foo', 'bar']));
     $this->toLdap()->toLdapFilter()->shouldEqual('(|(&(&(objectCategory=person)(objectClass=user))(userWorkstations=*foo,bar*))(&(objectClass=organizationalUnit)))');
 }
コード例 #5
0
 function it_should_hydrate_the_ldap_filter_for_a_query_operation_based_off_the_current_alias($connection)
 {
     $this->setLdapConnection($connection);
     $gSchema = $this->parser->parse('ad', 'group');
     $operators = new OperatorCollection();
     $operators->addLdapObjectSchema($this->schema, 'u');
     $operators->addLdapObjectSchema($gSchema, 'g');
     $operators->add(new Comparison('g.foo', '=', 'bar'));
     $operators->add(new Comparison('u.bar', '=', 'foo'));
     $operation = new QueryOperation($operators);
     $this->setAlias('g');
     $this->hydrateToLdap($operation)->getFilter()->shouldBeEqualTo('(&(objectClass=group)(foo=bar))');
 }
コード例 #6
0
ファイル: LdapQuerySpec.php プロジェクト: ldaptools/ldaptools
 function it_should_limit_the_results_for_subsequent_operations_if_a_size_limit_is_set_so_we_dont_go_over_the_limit($connection)
 {
     $foo = new LdapObjectSchema('foo', 'foo');
     $bar = new LdapObjectSchema('foo', 'bar');
     $foo->setFilter(new Comparison('foo', '=', 'bar'));
     $bar->setFilter(new Comparison('bar', '=', 'foo'));
     $filter = new OperatorCollection();
     $filter->addLdapObjectSchema($foo);
     $filter->addLdapObjectSchema($bar);
     $this->operation->setFilter($filter);
     $this->operation->setAttributes([]);
     $this->operation->setSizeLimit(4);
     $connection->execute(Argument::that(function ($op) {
         return $op->getFilter() == '(foo=bar)' && $op->getSizeLimit() == 4;
     }))->shouldBeCalled()->willReturn($this->ldapEntries);
     // The above returns 2 results, since the limit is 4 this next call should be set to a max of 2...
     $connection->execute(Argument::that(function ($op) {
         return $op->getFilter() == '(bar=foo)' && $op->getSizeLimit() == 2;
     }))->shouldBeCalled()->willReturn($this->sortEntries);
     $this->getResult();
 }