setAttributesToSelect() public method

Set the attributes that will be retrieved by default when using LdapQueryBuilder or a Repository.
public setAttributesToSelect ( array $attributes )
$attributes array
 function it_should_pass_operation_options_on_to_the_LdapQuery_class_correctly()
 {
     $this->objectSchema->setAttributesToSelect(['foo', 'bar']);
     $this->select();
     $this->from($this->objectSchema);
     $this->setScopeOneLevel();
     $this->setBaseDn('ou=stuff,dc=foo,dc=bar');
     $this->setPageSize('9001');
     $this->getLdapQuery()->getQueryOperation()->getAttributes()->shouldBeEqualTo([]);
     $this->getLdapQuery()->getQueryOperation()->getBaseDn()->shouldBeEqualTo('ou=stuff,dc=foo,dc=bar');
     $this->getLdapQuery()->getQueryOperation()->getScope()->shouldBeEqualTo(QueryOperation::SCOPE['ONELEVEL']);
     $this->getLdapQuery()->getQueryOperation()->getPageSize()->shouldBeEqualTo('9001');
     $this->getLdapQuery()->getQueryOperation()->getFilter()->toLdapFilter()->shouldBeEqualTo('(&(objectCategory=person)(objectClass=user))');
     $this->select('foo');
     $this->getLdapQuery()->getQueryOperation()->getAttributes()->shouldBeEqualTo(['foo']);
 }
Esempio n. 2
0
 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);
 }