mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
Merge branch 'MDL-80060' of https://github.com/paulholden/moodle
This commit is contained in:
commit
326c5ab3b1
@ -111,9 +111,9 @@ class enrol_manual_external extends external_api {
|
||||
}
|
||||
}
|
||||
if (empty($instance)) {
|
||||
$errorparams = new stdClass();
|
||||
$errorparams->courseid = $enrolment['courseid'];
|
||||
throw new moodle_exception('wsnoinstance', 'enrol_manual', $errorparams);
|
||||
$errorparams = new stdClass();
|
||||
$errorparams->courseid = $enrolment['courseid'];
|
||||
throw new moodle_exception('wsnoinstance', 'enrol_manual', '', $errorparams);
|
||||
}
|
||||
|
||||
// Check that the plugin accept enrolment (it should always the case, it's hard coded in the plugin).
|
||||
@ -195,7 +195,7 @@ class enrol_manual_external extends external_api {
|
||||
require_capability('enrol/manual:unenrol', $context);
|
||||
$instance = $DB->get_record('enrol', array('courseid' => $enrolment['courseid'], 'enrol' => 'manual'));
|
||||
if (!$instance) {
|
||||
throw new moodle_exception('wsnoinstance', 'enrol_manual', $enrolment);
|
||||
throw new moodle_exception('wsnoinstance', 'enrol_manual', '', $enrolment);
|
||||
}
|
||||
$user = $DB->get_record('user', array('id' => $enrolment['userid']));
|
||||
if (!$user) {
|
||||
|
@ -116,6 +116,10 @@ class externallib_test extends externallib_advanced_testcase {
|
||||
$this->fail('Exception expected if course does not have manual instance');
|
||||
} catch (\moodle_exception $e) {
|
||||
$this->assertSame('wsnoinstance', $e->errorcode);
|
||||
$this->assertSame(
|
||||
"Manual enrolment plugin instance doesn't exist or is disabled for the course (id = {$course2->id})",
|
||||
$e->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -274,14 +278,21 @@ class externallib_test extends externallib_advanced_testcase {
|
||||
} catch (\Exception $ex) {
|
||||
$this->assertTrue($ex instanceof \invalid_parameter_exception);
|
||||
}
|
||||
$DB->delete_records('enrol', array('id' => $enrolinstance->id));
|
||||
|
||||
// Call for course without manual instance.
|
||||
$DB->delete_records('user_enrolments');
|
||||
$DB->delete_records('enrol', ['courseid' => $course->id]);
|
||||
try {
|
||||
enrol_manual_external::unenrol_users(array(
|
||||
array('userid' => $student->id + 1, 'courseid' => $course->id),
|
||||
));
|
||||
$this->fail('Exception expected: invalid student id');
|
||||
} catch (\Exception $ex) {
|
||||
$this->assertTrue($ex instanceof \moodle_exception);
|
||||
$this->fail('Exception expected if course does not have manual instance');
|
||||
} catch (\moodle_exception $e) {
|
||||
$this->assertSame('wsnoinstance', $e->errorcode);
|
||||
$this->assertSame(
|
||||
"Manual enrolment plugin instance doesn't exist or is disabled for the course (id = {$course->id})",
|
||||
$e->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user