Skip to content

Commit

Permalink
ltb-project#31: Unit tests for get_attribute_values
Browse files Browse the repository at this point in the history
  • Loading branch information
abpai94 committed Sep 18, 2024
1 parent 0b2e433 commit 1ad645d
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/Ltb/LdapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,42 @@ public function test_sorted_search_without_sort_control(): void

}

public function test_get_attribute_values(): void
{

$ldap_connection = "ldap_connection";
$dn = "uid=test,ou=people,dc=my-domain,dc=com";
$pwdhistory = "pwdHistory";
$expectedValues = [
"count" => 2,
0 => 'secret',
1 => 'testpassword'
];

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

$phpLDAPMock->shouldreceive('ldap_read')
->with($ldap_connection, $dn, '(objectClass=*)', [ $pwdhistory ])
->andReturn("ldap_result");

$phpLDAPMock->shouldreceive('ldap_first_entry')
->with($ldap_connection, "ldap_result")
->andReturn("result_entry");

$phpLDAPMock->shouldreceive('ldap_get_values')
->with($ldap_connection, "result_entry", $pwdhistory)
->andReturn($expectedValues);

$ldapInstance = new \Ltb\Ldap( null, null, null, null, null, null, null, null );
$ldapInstance->ldap = $ldap_connection;
$value = $ldapInstance->get_attribute_values(
$dn,
$pwdhistory
);

$this->assertEquals(["count" => 2, 'secret', 'testpassword'] , $value, "incorrect array of attribute values returned by get_attribute_values");
}

public function test_get_password_value(): void
{

Expand Down

0 comments on commit 1ad645d

Please sign in to comment.