function it_should_NOT_enable_paging_when_executing_an_operation_that_disables_paging($pager) { $operation = new QueryOperation('(sAMAccountName=foo)', ['cn']); $operation->setUsePaging(false)->setBaseDn('example.local'); $pager->setIsEnabled(false)->shouldBeCalled(); $pager->start(null, 0)->shouldBeCalled(); $pager->next()->shouldBeCalled(); // Cannot simulate this without a connection. But the above control logic will be validated anyway. $this->shouldThrow('\\LdapTools\\Exception\\LdapConnectionException')->duringExecute($operation); $operation = new QueryOperation('(sAMAccountName=foo)', ['cn']); $operation->setScope(QueryOperation::SCOPE['BASE'])->setUsePaging(true)->setBaseDn('example.local'); // Cannot simulate this without a connection. But the above control logic will be validated anyway. $this->shouldThrow('\\LdapTools\\Exception\\LdapConnectionException')->duringExecute($operation); }
/** * @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)); } }