@@ -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