MDL-59365 enrol: Behat fixes
authorDamyon Wiese <damyon@moodle.com>
Thu, 13 Jul 2017 02:55:01 +0000 (10:55 +0800)
committerDamyon Wiese <damyon@moodle.com>
Thu, 13 Jul 2017 02:55:01 +0000 (10:55 +0800)
Fixes for the new enrol users popup with behat.

enrol/externallib.php
enrol/manual/ajax.php
enrol/manual/classes/enrol_users_form.php
enrol/tests/behat/behat_enrol.php

index ab0f699..f824422 100644 (file)
@@ -452,12 +452,13 @@ class core_enrol_external extends external_api {
                                                $params['perpage']);
 
         $results = array();
                                                $params['perpage']);
 
         $results = array();
+        $requiredfields = ['id', 'fullname', 'profileimageurl', 'profileimageurlsmall'];
         foreach ($users['users'] as $id => $user) {
             // Note: We pass the course here to validate that the current user can at least view user details in this course.
             // The user we are looking at is not in this course yet though - but we only fetch the minimal set of
             // user records, and the user has been validated to have course:enrolreview in this course. Otherwise
             // there is no way to find users who aren't in the course in order to enrol them.
         foreach ($users['users'] as $id => $user) {
             // Note: We pass the course here to validate that the current user can at least view user details in this course.
             // The user we are looking at is not in this course yet though - but we only fetch the minimal set of
             // user records, and the user has been validated to have course:enrolreview in this course. Otherwise
             // there is no way to find users who aren't in the course in order to enrol them.
-            if ($userdetails = user_get_user_details($user, $course)) {
+            if ($userdetails = user_get_user_details($user, $course, $requiredfields)) {
                 $results[] = $userdetails;
             }
         }
                 $results[] = $userdetails;
             }
         }
index 935f19b..a78f19c 100644 (file)
@@ -90,7 +90,7 @@ switch ($action) {
             }
         }
 
             }
         }
 
-        $roleid = optional_param('role', null, PARAM_INT);
+        $roleid = optional_param('roletoassign', null, PARAM_INT);
         $duration = optional_param('duration', 0, PARAM_FLOAT);
         $startdate = optional_param('startdate', 0, PARAM_INT);
         $recovergrades = optional_param('recovergrades', 0, PARAM_INT);
         $duration = optional_param('duration', 0, PARAM_FLOAT);
         $startdate = optional_param('startdate', 0, PARAM_INT);
         $recovergrades = optional_param('recovergrades', 0, PARAM_INT);
index f7c9ee8..089810e 100644 (file)
@@ -106,10 +106,10 @@ class enrol_manual_enrol_users_form extends moodleform {
         $mform->addElement('cohort', 'cohortlist', get_string('selectcohorts', 'enrol_manual'), $options);
 
         $roles = get_assignable_roles($context);
         $mform->addElement('cohort', 'cohortlist', get_string('selectcohorts', 'enrol_manual'), $options);
 
         $roles = get_assignable_roles($context);
-        $mform->addElement('select', 'role', get_string('assignrole', 'enrol_manual'), $roles);
+        $mform->addElement('select', 'roletoassign', get_string('assignrole', 'enrol_manual'), $roles);
         $keys = array_keys($roles);
         $defaultrole = end($keys);
         $keys = array_keys($roles);
         $defaultrole = end($keys);
-        $mform->setDefault('role', $defaultrole);
+        $mform->setDefault('roletoassign', $defaultrole);
 
         $mform->addAdvancedStatusElement('main');
 
 
         $mform->addAdvancedStatusElement('main');
 
index 3e6ae92..ca24f1d 100644 (file)
@@ -95,7 +95,7 @@ class behat_enrol extends behat_base {
         $this->execute("behat_forms::press_button", get_string('enrolusers', 'enrol'));
 
         if ($this->running_javascript()) {
         $this->execute("behat_forms::press_button", get_string('enrolusers', 'enrol'));
 
         if ($this->running_javascript()) {
-            $this->execute('behat_forms::i_set_the_field_to', array(get_string('assignroles', 'enrol_manual'), $rolename));
+            $this->execute('behat_forms::i_set_the_field_to', array(get_string('assignrole', 'enrol_manual'), $rolename));
 
             // We have a div here, not a tr.
             $this->execute('behat_forms::i_set_the_field_to', array(get_string('selectusers', 'enrol_manual'), $userfullname));
 
             // We have a div here, not a tr.
             $this->execute('behat_forms::i_set_the_field_to', array(get_string('selectusers', 'enrol_manual'), $userfullname));