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)'); }
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]); }
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))'); }
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)))'); }
function it_should_query_results_from_multiple_schema_types($connection) { $foo = new LdapObjectSchema('foo', 'foo'); $bar = new LdapObjectSchema('foo', 'bar'); $foo->setFilter(new Comparison('foo', '=', 'bar')); $bar->setFilter(new Comparison('bar', '=', 'foo')); $map = ['firstName' => 'givenname', 'lastName' => 'sn', 'created' => 'whencreated', 'name' => 'cn']; $bar->setAttributeMap($map); $bar->setAttributesToSelect(['name', 'created']); $bar->setConverterMap(['generalized_time' => ['created']]); $foo->setAttributeMap($map); $foo->setAttributesToSelect(['firstName', 'lastName']); $fb = new FilterBuilder(); $filter = new OperatorCollection(); $filter->addLdapObjectSchema($foo); $filter->addLdapObjectSchema($bar); $filter->add($fb->bAnd($fb->startsWith('foo.firstName', 'J'), $fb->startsWith('bar.name', 'Smith'), $fb->present('lastName'))); $this->operation->setFilter($filter); $this->operation->setAttributes([]); $connection->execute(Argument::that(function ($op) { return $op->getFilter() == '(&(foo=bar)(&(givenname=J*)(sn=*)))' && $op->getAttributes() == ['givenname', 'sn']; }))->shouldBeCalled()->willReturn($this->ldapEntries); $connection->execute(Argument::that(function ($op) { return $op->getFilter() == '(&(bar=foo)(&(cn=Smith*)(sn=*)))' && $op->getAttributes() == ['cn', 'whencreated']; }))->shouldBeCalled()->willReturn($this->sortEntries); $this->getResult()->count()->shouldBeEqualTo(4); $this->getArrayResult()->shouldHaveCount(4); }