MDL-37039 Assignment - Do not apply filters to grading table for offline assignments
[moodle.git] / backup / converter / moodle1 / tests / lib_test.php
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
17 /**
18  * Unit tests for the moodle1 converter
19  *
20  * @package    core_backup
21  * @subpackage backup-convert
22  * @category   phpunit
23  * @copyright  2011 Mark Nielsen <mark@moodlerooms.com>
24  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25  */
27 defined('MOODLE_INTERNAL') || die();
29 global $CFG;
30 require_once($CFG->dirroot . '/backup/converter/moodle1/lib.php');
33 class moodle1_converter_testcase extends advanced_testcase {
35     /** @var string the name of the directory containing the unpacked Moodle 1.9 backup */
36     protected $tempdir;
38     /** @var string saved hash of an icon file used during testing */
39     protected $iconhash;
41     protected function setUp() {
42         global $CFG;
44         $this->tempdir = convert_helper::generate_id('unittest');
45         check_dir_exists("$CFG->tempdir/backup/$this->tempdir/course_files/sub1");
46         check_dir_exists("$CFG->tempdir/backup/$this->tempdir/moddata/unittest/4/7");
47         copy(
48             "$CFG->dirroot/backup/converter/moodle1/tests/fixtures/moodle.xml",
49             "$CFG->tempdir/backup/$this->tempdir/moodle.xml"
50         );
51         copy(
52             "$CFG->dirroot/backup/converter/moodle1/tests/fixtures/icon.gif",
53             "$CFG->tempdir/backup/$this->tempdir/course_files/file1.gif"
54         );
55         copy(
56             "$CFG->dirroot/backup/converter/moodle1/tests/fixtures/icon.gif",
57             "$CFG->tempdir/backup/$this->tempdir/course_files/sub1/file2.gif"
58         );
59         copy(
60             "$CFG->dirroot/backup/converter/moodle1/tests/fixtures/icon.gif",
61             "$CFG->tempdir/backup/$this->tempdir/moddata/unittest/4/file1.gif"
62         );
63         copy(
64             "$CFG->dirroot/backup/converter/moodle1/tests/fixtures/icon.gif",
65             "$CFG->tempdir/backup/$this->tempdir/moddata/unittest/4/icon.gif"
66         );
67         $this->iconhash = sha1_file($CFG->tempdir.'/backup/'.$this->tempdir.'/moddata/unittest/4/icon.gif');
68         copy(
69             "$CFG->dirroot/backup/converter/moodle1/tests/fixtures/icon.gif",
70             "$CFG->tempdir/backup/$this->tempdir/moddata/unittest/4/7/icon.gif"
71         );
72     }
74     protected function tearDown() {
75         global $CFG;
76         if (empty($CFG->keeptempdirectoriesonbackup)) {
77             fulldelete("$CFG->tempdir/backup/$this->tempdir");
78         }
79     }
81     public function test_detect_format() {
82         $detected = moodle1_converter::detect_format($this->tempdir);
83         $this->assertEquals(backup::FORMAT_MOODLE1, $detected);
84     }
86     public function test_convert_factory() {
87         $converter = convert_factory::get_converter('moodle1', $this->tempdir);
88         $this->assertInstanceOf('moodle1_converter', $converter);
89     }
91     public function test_stash_storage_not_created() {
92         $converter = convert_factory::get_converter('moodle1', $this->tempdir);
93         $this->setExpectedException('moodle1_convert_storage_exception');
94         $converter->set_stash('tempinfo', 12);
95     }
97     public function test_stash_requiring_empty_stash() {
98         $this->resetAfterTest(true);
99         $converter = convert_factory::get_converter('moodle1', $this->tempdir);
100         $converter->create_stash_storage();
101         $converter->set_stash('tempinfo', 12);
102         $this->setExpectedException('moodle1_convert_empty_storage_exception');
103         try {
104             $converter->get_stash('anothertempinfo');
106         } catch (moodle1_convert_empty_storage_exception $e) {
107             // we must drop the storage here so we are able to re-create it in the next test
108             $converter->drop_stash_storage();
109             throw new moodle1_convert_empty_storage_exception('rethrowing');
110         }
111     }
113     public function test_stash_storage() {
114         $this->resetAfterTest(true);
115         $converter = convert_factory::get_converter('moodle1', $this->tempdir);
116         $converter->create_stash_storage();
118         // no implicit stashes
119         $stashes = $converter->get_stash_names();
120         $this->assertEquals(gettype($stashes), 'array');
121         $this->assertTrue(empty($stashes));
123         // test stashes without itemid
124         $converter->set_stash('tempinfo1', 12);
125         $converter->set_stash('tempinfo2', array('a' => 2, 'b' => 3));
126         $stashes = $converter->get_stash_names();
127         $this->assertEquals('array', gettype($stashes));
128         $this->assertEquals(2, count($stashes));
129         $this->assertTrue(in_array('tempinfo1', $stashes));
130         $this->assertTrue(in_array('tempinfo2', $stashes));
131         $this->assertEquals(12, $converter->get_stash('tempinfo1'));
132         $this->assertEquals(array('a' => 2, 'b' => 3), $converter->get_stash('tempinfo2'));
134         // overwriting a stashed value is allowed
135         $converter->set_stash('tempinfo1', '13');
136         $this->assertNotSame(13, $converter->get_stash('tempinfo1'));
137         $this->assertSame('13', $converter->get_stash('tempinfo1'));
139         // repeated reading is allowed
140         $this->assertEquals('13', $converter->get_stash('tempinfo1'));
142         // storing empty array
143         $converter->set_stash('empty_array_stash', array());
144         $restored = $converter->get_stash('empty_array_stash');
145         //$this->assertEquals(gettype($restored), 'array'); // todo return null now, this needs MDL-27713 to be fixed, then uncomment
146         $this->assertTrue(empty($restored));
148         // test stashes with itemid
149         $converter->set_stash('tempinfo', 'Hello', 1);
150         $converter->set_stash('tempinfo', 'World', 2);
151         $this->assertSame('Hello', $converter->get_stash('tempinfo', 1));
152         $this->assertSame('World', $converter->get_stash('tempinfo', 2));
154         // test get_stash_itemids()
155         $ids = $converter->get_stash_itemids('course_fileref');
156         $this->assertEquals(gettype($ids), 'array');
157         $this->assertTrue(empty($ids));
159         $converter->set_stash('course_fileref', null, 34);
160         $converter->set_stash('course_fileref', null, 52);
161         $ids = $converter->get_stash_itemids('course_fileref');
162         $this->assertEquals(2, count($ids));
163         $this->assertTrue(in_array(34, $ids));
164         $this->assertTrue(in_array(52, $ids));
166         $converter->drop_stash_storage();
167     }
169     public function test_get_stash_or_default() {
170         $this->resetAfterTest(true);
171         $converter = convert_factory::get_converter('moodle1', $this->tempdir);
172         $converter->create_stash_storage();
174         $this->assertTrue(is_null($converter->get_stash_or_default('stashname')));
175         $this->assertTrue(is_null($converter->get_stash_or_default('stashname', 7)));
176         $this->assertTrue('default' === $converter->get_stash_or_default('stashname', 0, 'default'));
177         $this->assertTrue(array('foo', 'bar') === $converter->get_stash_or_default('stashname', 42, array('foo', 'bar')));
179         //$converter->set_stash('stashname', 0);
180         //$this->assertFalse(is_null($converter->get_stash_or_default('stashname'))); // todo returns true now, this needs MDL-27713 to be fixed
182         //$converter->set_stash('stashname', '');
183         //$this->assertFalse(is_null($converter->get_stash_or_default('stashname'))); // todo returns true now, this needs MDL-27713 to be fixed
185         //$converter->set_stash('stashname', array());
186         //$this->assertFalse(is_null($converter->get_stash_or_default('stashname'))); // todo returns true now, this needs MDL-27713 to be fixed
188         $converter->set_stash('stashname', 42);
189         $this->assertTrue(42 === $converter->get_stash_or_default('stashname'));
190         $this->assertTrue(is_null($converter->get_stash_or_default('stashname', 1)));
191         $this->assertTrue(42 === $converter->get_stash_or_default('stashname', 0, 61));
193         $converter->set_stash('stashname', array(42 => (object)array('id' => 42)), 18);
194         $stashed = $converter->get_stash_or_default('stashname', 18, 1984);
195         $this->assertEquals(gettype($stashed), 'array');
196         $this->assertTrue(is_object($stashed[42]));
197         $this->assertTrue($stashed[42]->id === 42);
199         $converter->drop_stash_storage();
200     }
202     public function test_get_contextid() {
203         $this->resetAfterTest(true);
205         $converter = convert_factory::get_converter('moodle1', $this->tempdir);
207         // stash storage must be created in advance
208         $converter->create_stash_storage();
210         // ids are generated on the first call
211         $id1 = $converter->get_contextid(CONTEXT_BLOCK, 10);
212         $id2 = $converter->get_contextid(CONTEXT_BLOCK, 11);
213         $id3 = $converter->get_contextid(CONTEXT_MODULE, 10);
215         $this->assertNotEquals($id1, $id2);
216         $this->assertNotEquals($id1, $id3);
217         $this->assertNotEquals($id2, $id3);
219         // and then re-used if called with the same params
220         $this->assertEquals($id1, $converter->get_contextid(CONTEXT_BLOCK, 10));
221         $this->assertEquals($id2, $converter->get_contextid(CONTEXT_BLOCK, 11));
222         $this->assertEquals($id3, $converter->get_contextid(CONTEXT_MODULE, 10));
224         // for system and course level, the instance is irrelevant
225         // as we need only one system and one course
226         $id1 = $converter->get_contextid(CONTEXT_COURSE);
227         $id2 = $converter->get_contextid(CONTEXT_COURSE, 10);
228         $id3 = $converter->get_contextid(CONTEXT_COURSE, 14);
230         $this->assertEquals($id1, $id2);
231         $this->assertEquals($id1, $id3);
233         $id1 = $converter->get_contextid(CONTEXT_SYSTEM);
234         $id2 = $converter->get_contextid(CONTEXT_SYSTEM, 11);
235         $id3 = $converter->get_contextid(CONTEXT_SYSTEM, 15);
237         $this->assertEquals($id1, $id2);
238         $this->assertEquals($id1, $id3);
240         $converter->drop_stash_storage();
241     }
243     public function test_get_nextid() {
244         $this->resetAfterTest(true);
246         $converter = convert_factory::get_converter('moodle1', $this->tempdir);
248         $id1 = $converter->get_nextid();
249         $id2 = $converter->get_nextid();
250         $id3 = $converter->get_nextid();
252         $this->assertTrue(0 < $id1);
253         $this->assertTrue($id1 < $id2);
254         $this->assertTrue($id2 < $id3);
255     }
257     public function test_migrate_file() {
258         $this->resetAfterTest(true);
260         // set-up the file manager
261         $converter = convert_factory::get_converter('moodle1', $this->tempdir);
262         $converter->create_stash_storage();
263         $contextid = $converter->get_contextid(CONTEXT_MODULE, 32);
264         $fileman   = $converter->get_file_manager($contextid, 'mod_unittest', 'testarea');
265         // this fileman has not converted anything yet
266         $fileids = $fileman->get_fileids();
267         $this->assertEquals(gettype($fileids), 'array');
268         $this->assertEquals(0, count($fileids));
269         // try to migrate a non-existing directory
270         $returned = $fileman->migrate_directory('not/existing/directory');
271         $this->assertEquals(gettype($returned), 'array');
272         $this->assertEquals(0, count($returned));
273         $fileids = $fileman->get_fileids();
274         $this->assertEquals(gettype($fileids), 'array');
275         $this->assertEquals(0, count($fileids));
276         // try to migrate an invalid file
277         $fileman->itemid = 1;
278         $thrown = false;
279         try {
280             $fileman->migrate_file('/../../../../../../../../../../../../../../etc/passwd');
281         } catch (moodle1_convert_exception $e) {
282             $thrown = true;
283         }
284         $this->assertTrue($thrown);
285         // migrate a single file
286         $fileman->itemid = 4;
287         $fileman->migrate_file('moddata/unittest/4/icon.gif');
288         $subdir = substr($this->iconhash, 0, 2);
289         $this->assertTrue(is_file($converter->get_workdir_path().'/files/'.$subdir.'/'.$this->iconhash));
290         // get the file id
291         $fileids = $fileman->get_fileids();
292         $this->assertEquals(gettype($fileids), 'array');
293         $this->assertEquals(1, count($fileids));
294         // migrate another single file into another file area
295         $fileman->filearea = 'anotherarea';
296         $fileman->itemid = 7;
297         $fileman->migrate_file('moddata/unittest/4/7/icon.gif', '/', 'renamed.gif');
298         // get the file records
299         $filerecordids = $converter->get_stash_itemids('files');
300         foreach ($filerecordids as $filerecordid) {
301             $filerecord = $converter->get_stash('files', $filerecordid);
302             $this->assertEquals($this->iconhash, $filerecord['contenthash']);
303             $this->assertEquals($contextid, $filerecord['contextid']);
304             $this->assertEquals('mod_unittest', $filerecord['component']);
305             if ($filerecord['filearea'] === 'testarea') {
306                 $this->assertEquals(4, $filerecord['itemid']);
307                 $this->assertEquals('icon.gif', $filerecord['filename']);
308             }
309         }
310         // explicitly clear the list of migrated files
311         $this->assertTrue(count($fileman->get_fileids()) > 0);
312         $fileman->reset_fileids();
313         $this->assertTrue(count($fileman->get_fileids()) == 0);
314         $converter->drop_stash_storage();
315     }
317     public function test_convert_path() {
318         $path = new convert_path('foo_bar', '/ROOT/THINGS/FOO/BAR');
319         $this->assertEquals('foo_bar', $path->get_name());
320         $this->assertEquals('/ROOT/THINGS/FOO/BAR', $path->get_path());
321         $this->assertEquals('process_foo_bar', $path->get_processing_method());
322         $this->assertEquals('on_foo_bar_start', $path->get_start_method());
323         $this->assertEquals('on_foo_bar_end', $path->get_end_method());
324     }
326     public function test_convert_path_implicit_recipes() {
327         $path = new convert_path('foo_bar', '/ROOT/THINGS/FOO/BAR');
328         $data = array(
329             'ID' => 76,
330             'ELOY' => 'stronk7',
331             'MARTIN' => 'moodler',
332             'EMPTY' => null,
333         );
334         // apply default recipes (converting keys to lowercase)
335         $data = $path->apply_recipes($data);
336         $this->assertEquals(4, count($data));
337         $this->assertEquals(76, $data['id']);
338         $this->assertEquals('stronk7', $data['eloy']);
339         $this->assertEquals('moodler', $data['martin']);
340         $this->assertSame(null, $data['empty']);
341     }
343     public function test_convert_path_explicit_recipes() {
344         $path = new convert_path(
345             'foo_bar', '/ROOT/THINGS/FOO/BAR',
346             array(
347                 'newfields' => array(
348                     'david' => 'mudrd8mz',
349                     'petr'  => 'skodak',
350                 ),
351                 'renamefields' => array(
352                     'empty' => 'nothing',
353                 ),
354                 'dropfields' => array(
355                     'id'
356                 ),
357             )
358         );
359         $data = array(
360             'ID' => 76,
361             'ELOY' => 'stronk7',
362             'MARTIN' => 'moodler',
363             'EMPTY' => null,
364         );
365         $data = $path->apply_recipes($data);
367         $this->assertEquals(5, count($data));
368         $this->assertFalse(array_key_exists('id', $data));
369         $this->assertEquals('stronk7', $data['eloy']);
370         $this->assertEquals('moodler', $data['martin']);
371         $this->assertEquals('mudrd8mz', $data['david']);
372         $this->assertEquals('skodak', $data['petr']);
373         $this->assertSame(null, $data['nothing']);
374     }
376     public function test_grouped_data_on_nongrouped_convert_path() {
377         // prepare some grouped data
378         $data = array(
379             'ID' => 77,
380             'NAME' => 'Pale lagers',
381             'BEERS' => array(
382                 array(
383                     'BEER' => array(
384                         'ID' => 67,
385                         'NAME' => 'Pilsner Urquell',
386                     )
387                 ),
388                 array(
389                     'BEER' => array(
390                         'ID' => 34,
391                         'NAME' => 'Heineken',
392                     )
393                 ),
394             )
395         );
397         // declare a non-grouped path
398         $path = new convert_path('beer_style', '/ROOT/BEER_STYLES/BEER_STYLE');
400         // an attempt to apply recipes throws exception because we do not expect grouped data
401         $this->setExpectedException('convert_path_exception');
402         $data = $path->apply_recipes($data);
403     }
405     public function test_grouped_convert_path_with_recipes() {
406         // prepare some grouped data
407         $data = array(
408             'ID' => 77,
409             'NAME' => 'Pale lagers',
410             'BEERS' => array(
411                 array(
412                     'BEER' => array(
413                         'ID' => 67,
414                         'NAME' => 'Pilsner Urquell',
415                     )
416                 ),
417                 array(
418                     'BEER' => array(
419                         'ID' => 34,
420                         'NAME' => 'Heineken',
421                     )
422                 ),
423             )
424         );
426         // implict recipes work for grouped data if the path is declared as grouped
427         $path = new convert_path('beer_style', '/ROOT/BEER_STYLES/BEER_STYLE', array(), true);
428         $data = $path->apply_recipes($data);
429         $this->assertEquals('Heineken', $data['beers'][1]['beer']['name']);
431         // an attempt to provide explicit recipes on grouped elements throws exception
432         $this->setExpectedException('convert_path_exception');
433         $path = new convert_path(
434             'beer_style', '/ROOT/BEER_STYLES/BEER_STYLE',
435             array(
436                 'renamefields' => array(
437                     'name' => 'beername',   // note this is confusing recipe because the 'name' is used for both
438                     // beer-style name ('Pale lagers') and beer name ('Pilsner Urquell')
439                 )
440             ), true);
441     }
443     public function test_referenced_course_files() {
445         $text = 'This is a text containing links to file.php
446 as it is parsed from the backup file. <br /><br /><img border="0" width="110" vspace="0" hspace="0" height="92" title="News" alt="News" src="$@FILEPHP@$$@SLASH@$pics$@SLASH@$news.gif" /><a href="$@FILEPHP@$$@SLASH@$pics$@SLASH@$news.gif$@FORCEDOWNLOAD@$">download image</a><br />
447     <div><a href=\'$@FILEPHP@$/../../../../../../../../../../../../../../../etc/passwd\'>download passwords</a></div>
448     <div><a href=\'$@FILEPHP@$$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$etc$@SLASH@$shadow\'>download shadows</a></div>
449     <br /><a href=\'$@FILEPHP@$$@SLASH@$MANUAL.DOC$@FORCEDOWNLOAD@$\'>download manual</a><br />';
451         $files = moodle1_converter::find_referenced_files($text);
452         $this->assertEquals(gettype($files), 'array');
453         $this->assertEquals(2, count($files));
454         $this->assertTrue(in_array('/pics/news.gif', $files));
455         $this->assertTrue(in_array('/MANUAL.DOC', $files));
457         $text = moodle1_converter::rewrite_filephp_usage($text, array('/pics/news.gif', '/another/file/notused.txt'));
458         $this->assertEquals($text, 'This is a text containing links to file.php
459 as it is parsed from the backup file. <br /><br /><img border="0" width="110" vspace="0" hspace="0" height="92" title="News" alt="News" src="@@PLUGINFILE@@/pics/news.gif" /><a href="@@PLUGINFILE@@/pics/news.gif?forcedownload=1">download image</a><br />
460     <div><a href=\'$@FILEPHP@$/../../../../../../../../../../../../../../../etc/passwd\'>download passwords</a></div>
461     <div><a href=\'$@FILEPHP@$$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$..$@SLASH@$etc$@SLASH@$shadow\'>download shadows</a></div>
462     <br /><a href=\'$@FILEPHP@$$@SLASH@$MANUAL.DOC$@FORCEDOWNLOAD@$\'>download manual</a><br />');
463     }
465     public function test_referenced_files_urlencoded() {
467         $text = 'This is a text containing links to file.php
468 as it is parsed from the backup file. <br /><br /><img border="0" width="110" vspace="0" hspace="0" height="92" title="News" alt="News" src="$@FILEPHP@$$@SLASH@$pics$@SLASH@$news.gif" /><a href="$@FILEPHP@$$@SLASH@$pics$@SLASH@$news.gif$@FORCEDOWNLOAD@$">no space</a><br />
469     <br /><a href=\'$@FILEPHP@$$@SLASH@$pics$@SLASH@$news%20with%20spaces.gif$@FORCEDOWNLOAD@$\'>with urlencoded spaces</a><br />
470 <a href="$@FILEPHP@$$@SLASH@$illegal%20pics%2Bmovies$@SLASH@$romeo%2Bjuliet.avi">Download the full AVI for free! (space and plus encoded)</a>
471 <a href="$@FILEPHP@$$@SLASH@$illegal pics+movies$@SLASH@$romeo+juliet.avi">Download the full AVI for free! (none encoded)</a>
472 <a href="$@FILEPHP@$$@SLASH@$illegal%20pics+movies$@SLASH@$romeo+juliet.avi">Download the full AVI for free! (only space encoded)</a>
473 <a href="$@FILEPHP@$$@SLASH@$illegal pics%2Bmovies$@SLASH@$romeo%2Bjuliet.avi">Download the full AVI for free! (only plus)</a>';
475         $files = moodle1_converter::find_referenced_files($text);
476         $this->assertEquals(gettype($files), 'array');
477         $this->assertEquals(3, count($files));
478         $this->assertTrue(in_array('/pics/news.gif', $files));
479         $this->assertTrue(in_array('/pics/news with spaces.gif', $files));
480         $this->assertTrue(in_array('/illegal pics+movies/romeo+juliet.avi', $files));
482         $text = moodle1_converter::rewrite_filephp_usage($text, $files);
483         $this->assertEquals('This is a text containing links to file.php
484 as it is parsed from the backup file. <br /><br /><img border="0" width="110" vspace="0" hspace="0" height="92" title="News" alt="News" src="@@PLUGINFILE@@/pics/news.gif" /><a href="@@PLUGINFILE@@/pics/news.gif?forcedownload=1">no space</a><br />
485     <br /><a href=\'@@PLUGINFILE@@/pics/news%20with%20spaces.gif?forcedownload=1\'>with urlencoded spaces</a><br />
486 <a href="@@PLUGINFILE@@/illegal%20pics%2Bmovies/romeo%2Bjuliet.avi">Download the full AVI for free! (space and plus encoded)</a>
487 <a href="@@PLUGINFILE@@/illegal%20pics%2Bmovies/romeo%2Bjuliet.avi">Download the full AVI for free! (none encoded)</a>
488 <a href="$@FILEPHP@$$@SLASH@$illegal%20pics+movies$@SLASH@$romeo+juliet.avi">Download the full AVI for free! (only space encoded)</a>
489 <a href="$@FILEPHP@$$@SLASH@$illegal pics%2Bmovies$@SLASH@$romeo%2Bjuliet.avi">Download the full AVI for free! (only plus)</a>', $text);
490     }
492     public function test_question_bank_conversion() {
493         global $CFG;
495         $this->resetAfterTest(true);
497         copy(
498             "$CFG->dirroot/backup/converter/moodle1/tests/fixtures/questions.xml",
499             "$CFG->tempdir/backup/$this->tempdir/moodle.xml"
500         );
501         $converter = convert_factory::get_converter('moodle1', $this->tempdir);
502         $converter->convert();
503     }
505     public function test_convert_run_convert() {
506         $this->resetAfterTest(true);
507         $converter = convert_factory::get_converter('moodle1', $this->tempdir);
508         $converter->convert();
509     }
511     public function test_inforef_manager() {
512         $converter = convert_factory::get_converter('moodle1', $this->tempdir);
513         $inforef = $converter->get_inforef_manager('unittest');
514         $inforef->add_ref('file', 45);
515         $inforef->add_refs('file', array(46, 47));
516         // todo test the write_refs() via some dummy xml_writer
517         $this->setExpectedException('coding_exception');
518         $inforef->add_ref('unknown_referenced_item_name', 76);
519     }