mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 00:42:54 +02:00
Merge branch 'MDL-67210-master' of git://github.com/lucaboesch/moodle
This commit is contained in:
commit
ae2746b6b2
@ -720,6 +720,12 @@ class tool_uploadcourse_course {
|
||||
}
|
||||
}
|
||||
|
||||
// Visibility can only be 0 or 1.
|
||||
if (!empty($coursedata['visible']) AND !($coursedata['visible'] == 0 OR $coursedata['visible'] == 1)) {
|
||||
$this->error('invalidvisibilitymode', new lang_string('invalidvisibilitymode', 'tool_uploadcourse'));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Saving data.
|
||||
$this->data = $coursedata;
|
||||
$this->enrolmentdata = tool_uploadcourse_helper::get_enrolment_data($this->rawdata);
|
||||
|
@ -90,6 +90,7 @@ $string['invalidcsvfile'] = 'Invalid input CSV file';
|
||||
$string['invalidencoding'] = 'Invalid encoding';
|
||||
$string['invalidmode'] = 'Invalid mode selected';
|
||||
$string['invalideupdatemode'] = 'Invalid update mode selected';
|
||||
$string['invalidvisibilitymode'] = 'Invalid visibility mode given';
|
||||
$string['invalidroles'] = 'Invalid role names: {$a}';
|
||||
$string['invalidshortname'] = 'Invalid shortname';
|
||||
$string['missingmandatoryfields'] = 'Missing value for mandatory fields: {$a}';
|
||||
|
@ -82,6 +82,16 @@ class tool_uploadcourse_course_testcase extends advanced_testcase {
|
||||
$this->assertArrayHasKey('invalidshortname', $co->get_errors());
|
||||
}
|
||||
|
||||
public function test_invalid_visibility() {
|
||||
$this->resetAfterTest(true);
|
||||
$mode = tool_uploadcourse_processor::MODE_CREATE_NEW;
|
||||
$updatemode = tool_uploadcourse_processor::UPDATE_NOTHING;
|
||||
$data = array('shortname' => 'test', 'fullname' => 'New course', 'summary' => 'New', 'category' => 1, 'visible' => 2);
|
||||
$co = new tool_uploadcourse_course($mode, $updatemode, $data);
|
||||
$this->assertFalse($co->prepare());
|
||||
$this->assertArrayHasKey('invalidvisibilitymode', $co->get_errors());
|
||||
}
|
||||
|
||||
public function test_create() {
|
||||
global $DB;
|
||||
$this->resetAfterTest(true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user