Skip to content

Commit 9dedb86

Browse files
committed
Update restore test for Moodle 5.
1 parent e4f9b9f commit 9dedb86

File tree

5 files changed

+39
-14
lines changed

5 files changed

+39
-14
lines changed

changehistory.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Add a QUIZ variable to the Twig context with fields QUIZ.name and QUIZ.tags. Allows customising the behaviour
99
of CodeRunner questions according to the quiz in which they're running.
1010
* Extend TwigAll to include penalty regime.
11-
* Improve resilience of combinator template grader code to bad response from author's template.
11+
* Improve resilience of combinator template grader code to bad responses from author's template.
1212
* Improvements to test suite (issues #266, #267 and #276)
1313
* Bug fix: when using equality grader, trailing space characters were correctly being removed from
1414
all lines but the spec said all whitespace characters were being removed. That wasn't true - characters
27.3 KB
Binary file not shown.

tests/restore_test.php

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,29 +117,34 @@ protected function load_question_data_by_name($name) {
117117

118118
public function test_restore_from_v3_1_2(): void {
119119
global $CFG;
120-
$this->restore_backup($CFG->dirroot .
121-
'/question/type/coderunner/tests/fixtures/loadtesting_pseudocourse_backup_V3.1.2.mbz');
120+
$moodleversion = (float) get_config('core', 'release');
121+
if ($moodleversion >= 5) {
122+
$this->markTestSkipped('This test fails on Moodle 5 due to warnings.');
123+
} else {
124+
$this->restore_backup($CFG->dirroot .
125+
'/question/type/coderunner/tests/fixtures/backuptester_V3.1.2.mbz');
122126

123-
// Verify some restored questions look OK.
124-
[$options, $tests] = $this->load_question_data_by_name('c_to_fpy3');
125-
$this->assertCount(3, $tests);
126-
$this->assertNull($options->template);
127+
// Verify a couple of restored questions look OK.
128+
[$options, $tests] = $this->load_question_data_by_name('c_to_fpy3');
129+
$this->assertCount(3, $tests);
130+
$this->assertNull($options->template);
127131

128-
[$options, $tests] = $this->load_question_data_by_name('PROTOTYPE_clojure_with_combinator');
129-
$this->assertCount(1, $tests);
130-
$this->assertStringStartsWith('import subprocess', $options->template);
132+
[$options, $tests] = $this->load_question_data_by_name('PROTOTYPE_clojure_with_combinator');
133+
$this->assertCount(1, $tests);
134+
$this->assertStringStartsWith('import subprocess', $options->template);
135+
}
131136
}
132137

133138
public function test_restore_from_v4_5_3(): void {
134139
global $CFG;
135140
$moodleversion = (float) get_config('core', 'release');
136-
if ($moodleversion < 4.5) {
137-
$this->markTestSkipped('This test requires Moodle 4.5.3 or later.');
141+
if ($moodleversion < 4.5 || $moodleversion >= 5) {
142+
$this->markTestSkipped('This test requires Moodle 4.5.3 or later and less than Moodle 5.');
138143
} else {
139144
$this->restore_backup($CFG->dirroot .
140-
'/question/type/coderunner/tests/fixtures/loadtesting_pseudocourse_backup_V4.5.3.mbz');
145+
'/question/type/coderunner/tests/fixtures/backuptester_V4.5.3.mbz');
141146

142-
// Verify some restored questions look OK.
147+
// Verify a couple of restored questions look OK.
143148
[$options, $tests] = $this->load_question_data_by_name('c_to_fpy3');
144149
$this->assertCount(3, $tests);
145150
$this->assertNull($options->template);
@@ -149,4 +154,24 @@ public function test_restore_from_v4_5_3(): void {
149154
$this->assertStringStartsWith('import subprocess', $options->template);
150155
}
151156
}
157+
158+
public function test_restore_from_v5_0_3(): void {
159+
global $CFG;
160+
$moodleversion = (float) get_config('core', 'release');
161+
if ($moodleversion < 5) {
162+
$this->markTestSkipped('This test requires Moodle 5.0 or later.');
163+
} else {
164+
$this->restore_backup($CFG->dirroot .
165+
'/question/type/coderunner/tests/fixtures/backuptester_V5.0.3.mbz');
166+
167+
// Verify a couple of restored questions look OK.
168+
[$options, $tests] = $this->load_question_data_by_name('Question in quiz');
169+
$this->assertCount(1, $tests);
170+
$this->assertNull($options->template);
171+
172+
[$options, $tests] = $this->load_question_data_by_name('Java Class: bod');
173+
$this->assertCount(3, $tests);
174+
$this->assertNull($options->template);
175+
}
176+
}
152177
}

0 commit comments

Comments
 (0)