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(); }
/** * @param QueryOperation $operation */ protected function hydrateQueryOperation(QueryOperation $operation) { $operation->setAttributes($this->getAttributesToLdap($operation->getAttributes(), true, $this->schema, $this->alias)); // Only want it set if it wasn't explicitly set... if ($this->schema && is_null($operation->getBaseDn())) { $operation->setBaseDn($this->schema->getBaseDn()); } // Empty check instead of null due to the way the BaseDN is set for a RootDSE query... if (!empty($operation->getBaseDn()) && ParameterResolver::hasParameters($operation->getBaseDn())) { $this->setDefaultParameters(); $operation->setBaseDn($this->resolveParameters(['baseDn' => $operation->getBaseDn()])['baseDn']); } // If null then we default to the domain config or the explicitly set value... if ($this->schema && !is_null($this->schema->getUsePaging())) { $operation->setUsePaging($this->schema->getUsePaging()); } if ($this->schema && !is_null($this->schema->getScope())) { $operation->setScope($this->schema->getScope()); } if ($this->schema) { $operation->addControl(...$this->schema->getControls()); } if ($operation->getFilter() instanceof OperatorCollection) { $this->convertValuesToLdap($operation->getFilter()); $operation->setFilter($operation->getFilter()->toLdapFilter($this->alias)); } }