From 011d55dd6262fc8a57a7ef9197c5a496d37d1b5f Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Wed, 27 Nov 2019 23:40:09 +0100 Subject: [PATCH] MDL-67118 enrol_ldap: add pagesize/subcontexts provider With that provider we'll be explicitly checking that any pagesize and subcontexts search is returning results consistently so the internal paging/servercontrols work as expected. --- enrol/ldap/tests/ldap_test.php | 35 +++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/enrol/ldap/tests/ldap_test.php b/enrol/ldap/tests/ldap_test.php index 9ac6277ab4d..9893146415f 100644 --- a/enrol/ldap/tests/ldap_test.php +++ b/enrol/ldap/tests/ldap_test.php @@ -39,7 +39,36 @@ global $CFG; class enrol_ldap_testcase extends advanced_testcase { - public function test_enrol_ldap() { + /** + * Data provider for enrol_ldap tests + * + * Used to ensure that all the paged stuff works properly, irrespectively + * of the pagesize configured (that implies all the chunking and paging + * built in the plugis is doing its work consistently). Both searching and + * not searching within subcontexts. + * + * @return array[] + */ + public function enrol_ldap_provider() { + $pagesizes = [1, 3, 5, 1000]; + $subcontexts = [0, 1]; + $combinations = []; + foreach ($pagesizes as $pagesize) { + foreach ($subcontexts as $subcontext) { + $combinations["pagesize {$pagesize}, subcontexts {$subcontext}"] = [$pagesize, $subcontext]; + } + } + return $combinations; + } + + /** + * General enrol_ldap testcase + * + * @dataProvider enrol_ldap_provider + * @param int $pagesize Value to be configured in settings controlling page size. + * @param int $subcontext Value to be configured in settings controlling searching in subcontexts. + */ + public function test_enrol_ldap(int $pagesize, int $subcontext) { global $CFG, $DB; if (!extension_loaded('ldap')) { @@ -83,10 +112,10 @@ class enrol_ldap_testcase extends advanced_testcase { $enrol->set_config('start_tls', 0); $enrol->set_config('ldap_version', 3); $enrol->set_config('ldapencoding', 'utf-8'); - $enrol->set_config('pagesize', '2'); + $enrol->set_config('pagesize', $pagesize); $enrol->set_config('bind_dn', TEST_ENROL_LDAP_BIND_DN); $enrol->set_config('bind_pw', TEST_ENROL_LDAP_BIND_PW); - $enrol->set_config('course_search_sub', 0); + $enrol->set_config('course_search_sub', $subcontext); $enrol->set_config('memberattribute_isdn', 0); $enrol->set_config('user_contexts', ''); $enrol->set_config('user_search_sub', 0);