Skip to content

Commit

Permalink
Add unit test for matchDn function
Browse files Browse the repository at this point in the history
  • Loading branch information
coudot committed Nov 5, 2024
1 parent 190537a commit 3d2fae6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/Ltb/LdapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,28 @@ public function test_get_first_value_error(): void

}

public function test_matchDn(): void
{

$phpLDAPMock = Mockery::mock('overload:Ltb\PhpLDAP');

$phpLDAPMock->shouldreceive('ldap_search')
->with("ldap_connection", "ou=people,dc=my-domain,dc=com", "(&(objectClass=inetOrgPerson)(entryDn=uid=test,ou=people,dc=my-domain,dc=com))", [1.1])
->andReturn(array("ldap_search_result"));

$phpLDAPMock->shouldreceive('ldap_count_entries')
->with("ldap_connection", array("ldap_search_result"))
->andReturn(1);

$ldapInstance = new \Ltb\Ldap( null, null, null, null, null, null, null, null );
$ldapInstance->ldap = "ldap_connection";

$result_match = $ldapInstance->matchDn("uid=test,ou=people,dc=my-domain,dc=com", "entryDn", "(objectClass=inetOrgPerson)", "ou=people,dc=my-domain,dc=com", "sub");

$this->assertTrue($result_match, "DN match");

}

public function setUp(): void
{
// Turn on error reporting
Expand Down

0 comments on commit 3d2fae6

Please sign in to comment.