Files
roundcubemail/tests/Framework/LdapGeneric.php
Michael Voříšek 54f4aa33f9 Fix CS - imports (#9316)
* fix Tests\Browser\TestCase imports

* fix remaining imports

* fix PHPUnit\Framework\TestCase imports

* import GuzzleHttp\Client

* fix remaining

* "php_unit_method_casing" is not todo

* fix "single_line_comment_spacing"

* fix 2nd commit done using older fixer
2024-01-21 19:13:31 +01:00

51 lines
1.3 KiB
PHP

<?php
use PHPUnit\Framework\TestCase;
/**
* Test class to test rcube_ldap_generic class
*/
class Framework_LdapGeneric extends TestCase
{
protected function markTestSkippedIfNetLdapPackageIsNotInstalled(): void
{
if (!class_exists(Net_LDAP3::class)) {
$this->markTestSkipped('The Net_LDAP3 package not available.');
}
}
/**
* Class constructor
*/
public function test_class()
{
$this->markTestSkippedIfNetLdapPackageIsNotInstalled();
$object = new rcube_ldap_generic([]);
$this->assertInstanceOf('rcube_ldap_generic', $object, 'Class constructor');
}
/**
* Test fulltext_search_filter() method
*/
public function test_fulltext_search_filter()
{
$this->markTestSkippedIfNetLdapPackageIsNotInstalled();
$object = new rcube_ldap_generic([]);
$result = $object->fulltext_search_filter('test', ['dn']);
$this->assertSame('(|(dn=test))', $result);
$result = $object->fulltext_search_filter('test', ['dn', 'mail'], 2);
$this->assertSame('(|(dn=test*)(mail=test*))', $result);
$result = $object->fulltext_search_filter('test1 test2', ['dn', 'mail'], 0);
$this->assertSame('(&(|(dn=*test1*)(mail=*test1*))(|(dn=*test2*)(mail=*test2*)))', $result);
}
}