Skip to content

Commit

Permalink
First tests for Directory module
Browse files Browse the repository at this point in the history
  • Loading branch information
coudot committed Aug 29, 2024
1 parent 3076c23 commit 7ad99af
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/Ltb/DirectoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

require __DIR__ . '/../../vendor/autoload.php';
use PHPUnit\Framework\TestCase;

final class DirectoryTest extends \Mockery\Adapter\Phpunit\MockeryTestCase
{

public function test_openldap_islocked_locked_forever(): void
{
$phpLDAPMock = Mockery::mock('overload:Ltb\PhpLDAP');
$phpLDAPMock->shouldreceive([
'ldap_read' => null,
'ldap_errno' => 0,
'ldap_get_entries' => [
'count' => 1,
0 => [
'pwdaccountlockedtime' => [
'count' => 1,
0 => "000001010000Z",
]
]
]
]);

$isLocked = (new Ltb\Directory\OpenLDAP)->isLocked(null, null, null);
$this->assertTrue($isLocked, "Account should be locked forever");
}

public function test_openldap_islocked_not_locked(): void
{
$phpLDAPMock = Mockery::mock('overload:Ltb\PhpLDAP');
$phpLDAPMock->shouldreceive([
'ldap_read' => null,
'ldap_errno' => 0,
'ldap_get_entries' => [
'count' => 1,
0 => [
'pwdaccountlockedtime' => [
'count' => 1,
0 => null,
]
]
]
]);

$isLocked = (new Ltb\Directory\OpenLDAP)->isLocked(null, null, null);
$this->assertFalse($isLocked, "Account should not be locked");
}

}

0 comments on commit 7ad99af

Please sign in to comment.