From 2211c6be77a43e8467a32c723c645e826f987e83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20OUDOT?= Date: Tue, 17 Sep 2024 18:39:26 +0200 Subject: [PATCH] Tests for isAccountEnabled --- tests/Ltb/DirectoryTest.php | 42 +++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/Ltb/DirectoryTest.php b/tests/Ltb/DirectoryTest.php index 264f552..e4ce2f4 100644 --- a/tests/Ltb/DirectoryTest.php +++ b/tests/Ltb/DirectoryTest.php @@ -685,4 +685,46 @@ public function test_activedirectory_reset_false_empty(): void $this->assertFalse($reset, "Reset should be false"); } + public function test_activedirectory_isenabled_true(): void + { + $phpLDAPMock = Mockery::mock('overload:Ltb\PhpLDAP'); + $phpLDAPMock->shouldreceive([ + 'ldap_read' => null, + 'ldap_errno' => 0, + 'ldap_get_entries' => [ + 'count' => 1, + 0 => [ + 'useraccountcontrol' => [ + 'count' => 1, + 0 => 512, + ] + ] + ] + ]); + + $accountEnabled = (new Ltb\Directory\ActiveDirectory)->isAccountEnabled(null, null); + $this->assertTrue($accountEnabled, "Account should be enabled"); + } + + public function test_activedirectory_isenabled_false(): void + { + $phpLDAPMock = Mockery::mock('overload:Ltb\PhpLDAP'); + $phpLDAPMock->shouldreceive([ + 'ldap_read' => null, + 'ldap_errno' => 0, + 'ldap_get_entries' => [ + 'count' => 1, + 0 => [ + 'useraccountcontrol' => [ + 'count' => 1, + 0 => 514, + ] + ] + ] + ]); + + $accountEnabled = (new Ltb\Directory\ActiveDirectory)->isAccountEnabled(null, null); + $this->assertFalse($accountEnabled, "Account should be disabled"); + } + }