Skip to content

Commit

Permalink
Fix #15: Faulty presence filter initialization (#16)
Browse files Browse the repository at this point in the history
Fixes the NestingTrait to use the class PresenceFilter in the filterPresence() method. The use of FlatFilter results in an error as the class is not designed to handle presence filters.

Commits:
* Fix presence filter in nesting trait
* Add test
  • Loading branch information
strifel authored Aug 17, 2021
1 parent b63672f commit 285aca2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Query/Filter/NestingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ trait NestingTrait
*
* @return FlatFilter The filter to configure
*/
public function filterPresence(): FlatFilter
public function filterPresence(): PresenceFilter
{
return new FlatFilter($this, FilterInterface::PRESENCE);
return new PresenceFilter($this, FilterInterface::PRESENCE);
}

/**
Expand Down
15 changes: 15 additions & 0 deletions tests/IntegrationTests/Query/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,19 @@ public function testAddObjectClasses()

$this->assertSame('(&(objectClass=inetOrgPerson)(objectClass=person)(objectClass=top)(uid=FMüller))', $query->getFilter());
}

public function testPresenceFilter()
{
self::bootKernel();

$manager = static::$container->get('kagonlineteam_ldap.manager');

$query = (new Builder('ou=users,dc=example,dc=com', $manager->getMetadata(DummyUser::class)))
->filterPresence()
->on('username')
->end()
->make();

$this->assertSame('(&(objectClass=inetOrgPerson)(objectClass=person)(objectClass=top)(uid=*))', $query->getFilter());
}
}

0 comments on commit 285aca2

Please sign in to comment.