function it_should_correctly_add_attributes_to_select_based_off_aliases_in_the_order_by_selection($connection)
{
$this->setLdapConnection($connection);
$gSchema = $this->parser->parse('ad', 'group');
$operators = new OperatorCollection();
$operators->addLdapObjectSchema($this->schema, 'u');
$operators->addLdapObjectSchema($gSchema, 'g');
$operationSelect = new QueryOperation($operators);
$operationDefault = clone $operationSelect;
$operationSelect->setAttributes(['u.firstName', 'u.lastName', 'name', 'g.description', 'g.members']);
$operationDefault->setAttributes(['g.name', 'g.description']);
$this->setOrderBy(['g.sid' => LdapQuery::ORDER['DESC'], 'u.department' => LdapQuery::ORDER['ASC'], 'guid' => LdapQuery::ORDER['ASC'], 'u.lastName' => LdapQuery::ORDER['DESC']]);
// Any specifically selected attributes + specifically aliased attributes in the order by + generic in the order by.
// Should also avoid adding duplicates.
$this->setLdapObjectSchema($this->schema);
$this->setAlias('u');
$this->hydrateToLdap(clone $operationSelect)->getAttributes()->shouldBeEqualTo(['givenName', 'sn', 'cn', 'department', 'objectGuid']);
}