Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 39 and 311]

(no description)

File Size: 475 lines (18 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: ldaplib_test  - X-Ref

ldap tests.

test_ldap_addslashes()   X-Ref
No description

test_ldap_stripslashes()   X-Ref
No description

test_ldap_normalise_objectclass($args, $expected)   X-Ref
Tests for ldap_normalise_objectclass.

param: array $args Arguments passed to ldap_normalise_objectclass
param: string $expected The expected objectclass filter

ldap_normalise_objectclass_provider()   X-Ref
Data provider for the test_ldap_normalise_objectclass testcase.

return: array of testcases.

test_ldap_get_entries_moodle()   X-Ref
Tests for ldap_get_entries_moodle.

NOTE: in order to execute this test you need to set up OpenLDAP server with core,
cosine, nis and internet schemas and add configuration constants to
config.php or phpunit.xml configuration file.  The bind users *needs*
permissions to create objects in the LDAP server, under the bind domain.

define('TEST_LDAPLIB_HOST_URL', 'ldap://127.0.0.1');
define('TEST_LDAPLIB_BIND_DN', 'cn=someuser,dc=example,dc=local');
define('TEST_LDAPLIB_BIND_PW', 'somepassword');
define('TEST_LDAPLIB_DOMAIN',  'dc=example,dc=local');


get_ldap_get_entries_moodle_test_objects()   X-Ref
Provide the array of test objects for the ldap_get_entries_moodle test case.

return: array of test objects

create_test_container($connection, $container)   X-Ref
Create a new container in the LDAP domain, to hold the test objects. The
container is created as a domain component (dc) + organizational unit (ou) object.

param: object $connection Valid LDAP connection
param: string $container Name of the test container to create.
return: string or false Distinguished name for the created container, or false on error.

remove_test_container($connection, $containerdn)   X-Ref
Remove the container in the LDAP domain root that holds the test objects. The container
*must* be empty before trying to remove it. Otherwise this function fails.

param: object $connection Valid LDAP connection
param: string $containerdn The distinguished of the container to remove.

add_test_objects($connection, $containerdn, $testobjects)   X-Ref
Add the test objects to the test container.

param: resource $connection Valid LDAP connection
param: string $containerdn The distinguished name of the container for the created objects.
param: array $testobjects Array of the tests objects to create. The structure of
return: boolean True on success, false otherwise.

remove_test_objects($connection, $containerdn, $testobjects)   X-Ref
Remove the test objects from the test container.

param: resource $connection Valid LDAP connection
param: string $containerdn The distinguished name of the container for the objects to remove.
param: array $testobjects Array of the tests objects to create. The structure of

get_object_dn($object, $containerdn)   X-Ref
Get the distinguished name (DN) for a given object.

param: object $object The LDAP object to calculate the DN for.
param: string $containerdn The DN of the container to use for objects with relative DNs.
return: string The calculated DN.