-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
David Coutadeur
committed
Mar 29, 2024
1 parent
649ba2b
commit 5628e48
Showing
1 changed file
with
41 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,6 @@ | |
require __DIR__ . '/../../vendor/autoload.php'; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
// global variable for ldap_get_mail_for_notification function | ||
$GLOBALS['mail_attributes'] = array("mail"); | ||
|
||
final class AttributeValueTest extends \Mockery\Adapter\Phpunit\MockeryTestCase | ||
{ | ||
|
||
|
@@ -29,9 +26,28 @@ public function test_ldap_get_first_available_value(): void | |
|
||
} | ||
|
||
public function test_ldap_get_first_available_value_empty(): void | ||
{ | ||
|
||
$phpLDAPMock = Mockery::mock('overload:Ltb\PhpLDAP'); | ||
$phpLDAPMock->shouldreceive([ | ||
'ldap_get_attributes' => ['cn'], | ||
'ldap_get_values' => [ | ||
'count' => 0 | ||
] | ||
]); | ||
|
||
$ent = Ltb\AttributeValue::ldap_get_first_available_value(null, null, ['cn']); | ||
$this->assertFalse($ent, "not getting false result whereas no value has been returned"); | ||
|
||
} | ||
|
||
public function test_ldap_get_mail_for_notification(): void | ||
{ | ||
|
||
// global variable for ldap_get_mail_for_notification function | ||
$GLOBALS['mail_attributes'] = array("mail"); | ||
|
||
$phpLDAPMock = Mockery::mock('overload:Ltb\PhpLDAP'); | ||
$phpLDAPMock->shouldreceive([ | ||
'ldap_get_attributes' => ['mail'], | ||
|
@@ -42,9 +58,30 @@ public function test_ldap_get_mail_for_notification(): void | |
] | ||
]); | ||
|
||
# Test ldap_get_first_available_value | ||
# Test ldap_get_mail_for_notification | ||
$mail = Ltb\AttributeValue::ldap_get_mail_for_notification(null, null); | ||
$this->assertEquals('[email protected]', $mail, "not getting [email protected] as mail for notification"); | ||
} | ||
|
||
public function test_ldap_get_proxy_for_notification(): void | ||
{ | ||
|
||
// global variable for ldap_get_mail_for_notification function | ||
$GLOBALS['mail_attributes'] = array("proxyAddresses"); | ||
|
||
$phpLDAPMock = Mockery::mock('overload:Ltb\PhpLDAP'); | ||
$phpLDAPMock->shouldreceive([ | ||
'ldap_get_attributes' => ['proxyAddresses'], | ||
'ldap_get_values' => [ | ||
'count' => 2, | ||
0 => 'smtp:[email protected]', | ||
1 => 'smtp:[email protected]' | ||
] | ||
]); | ||
|
||
# Test ldap_get_mail_for_notification | ||
$mail = Ltb\AttributeValue::ldap_get_mail_for_notification(null, null); | ||
$this->assertEquals('[email protected]', $mail, "not getting [email protected] as proxyAddress for notification"); | ||
} | ||
|
||
} |