| Línea 90... |
Línea 90... |
| 90 |
if (empty($CFG->keeptempdirectoriesonbackup)) {
|
90 |
if (empty($CFG->keeptempdirectoriesonbackup)) {
|
| 91 |
fulldelete($this->tempdirpath);
|
91 |
fulldelete($this->tempdirpath);
|
| 92 |
}
|
92 |
}
|
| 93 |
}
|
93 |
}
|
| Línea 94... |
Línea 94... |
| 94 |
|
94 |
|
| 95 |
public function test_detect_format() {
|
95 |
public function test_detect_format(): void {
|
| 96 |
$detected = moodle1_converter::detect_format($this->tempdir);
|
96 |
$detected = moodle1_converter::detect_format($this->tempdir);
|
| 97 |
$this->assertEquals(backup::FORMAT_MOODLE1, $detected);
|
97 |
$this->assertEquals(backup::FORMAT_MOODLE1, $detected);
|
| Línea 98... |
Línea 98... |
| 98 |
}
|
98 |
}
|
| 99 |
|
99 |
|
| 100 |
public function test_convert_factory() {
|
100 |
public function test_convert_factory(): void {
|
| 101 |
$converter = convert_factory::get_converter('moodle1', $this->tempdir);
|
101 |
$converter = convert_factory::get_converter('moodle1', $this->tempdir);
|
| Línea 102... |
Línea 102... |
| 102 |
$this->assertInstanceOf('moodle1_converter', $converter);
|
102 |
$this->assertInstanceOf('moodle1_converter', $converter);
|
| 103 |
}
|
103 |
}
|
| 104 |
|
104 |
|
| 105 |
public function test_stash_storage_not_created() {
|
105 |
public function test_stash_storage_not_created(): void {
|
| 106 |
$converter = convert_factory::get_converter('moodle1', $this->tempdir);
|
106 |
$converter = convert_factory::get_converter('moodle1', $this->tempdir);
|
| Línea 107... |
Línea 107... |
| 107 |
$this->expectException(moodle1_convert_storage_exception::class);
|
107 |
$this->expectException(moodle1_convert_storage_exception::class);
|
| 108 |
$converter->set_stash('tempinfo', 12);
|
108 |
$converter->set_stash('tempinfo', 12);
|
| 109 |
}
|
109 |
}
|
| 110 |
|
110 |
|
| 111 |
public function test_stash_requiring_empty_stash() {
|
111 |
public function test_stash_requiring_empty_stash(): void {
|
| 112 |
$this->resetAfterTest(true);
|
112 |
$this->resetAfterTest(true);
|
| Línea 122... |
Línea 122... |
| 122 |
$converter->drop_stash_storage();
|
122 |
$converter->drop_stash_storage();
|
| 123 |
throw new moodle1_convert_empty_storage_exception('rethrowing');
|
123 |
throw new moodle1_convert_empty_storage_exception('rethrowing');
|
| 124 |
}
|
124 |
}
|
| 125 |
}
|
125 |
}
|
| Línea 126... |
Línea 126... |
| 126 |
|
126 |
|
| 127 |
public function test_stash_storage() {
|
127 |
public function test_stash_storage(): void {
|
| 128 |
$this->resetAfterTest(true);
|
128 |
$this->resetAfterTest(true);
|
| 129 |
$converter = convert_factory::get_converter('moodle1', $this->tempdir);
|
129 |
$converter = convert_factory::get_converter('moodle1', $this->tempdir);
|
| Línea 130... |
Línea 130... |
| 130 |
$converter->create_stash_storage();
|
130 |
$converter->create_stash_storage();
|
| Línea 178... |
Línea 178... |
| 178 |
$this->assertTrue(in_array(52, $ids));
|
178 |
$this->assertTrue(in_array(52, $ids));
|
| Línea 179... |
Línea 179... |
| 179 |
|
179 |
|
| 180 |
$converter->drop_stash_storage();
|
180 |
$converter->drop_stash_storage();
|
| Línea 181... |
Línea 181... |
| 181 |
}
|
181 |
}
|
| 182 |
|
182 |
|
| 183 |
public function test_get_stash_or_default() {
|
183 |
public function test_get_stash_or_default(): void {
|
| 184 |
$this->resetAfterTest(true);
|
184 |
$this->resetAfterTest(true);
|
| Línea 185... |
Línea 185... |
| 185 |
$converter = convert_factory::get_converter('moodle1', $this->tempdir);
|
185 |
$converter = convert_factory::get_converter('moodle1', $this->tempdir);
|
| Línea 211... |
Línea 211... |
| 211 |
$this->assertTrue($stashed[42]->id === 42);
|
211 |
$this->assertTrue($stashed[42]->id === 42);
|
| Línea 212... |
Línea 212... |
| 212 |
|
212 |
|
| 213 |
$converter->drop_stash_storage();
|
213 |
$converter->drop_stash_storage();
|
| Línea 214... |
Línea 214... |
| 214 |
}
|
214 |
}
|
| 215 |
|
215 |
|
| Línea 216... |
Línea 216... |
| 216 |
public function test_get_contextid() {
|
216 |
public function test_get_contextid(): void {
|
| Línea 217... |
Línea 217... |
| 217 |
$this->resetAfterTest(true);
|
217 |
$this->resetAfterTest(true);
|
| Línea 252... |
Línea 252... |
| 252 |
$this->assertEquals($id1, $id3);
|
252 |
$this->assertEquals($id1, $id3);
|
| Línea 253... |
Línea 253... |
| 253 |
|
253 |
|
| 254 |
$converter->drop_stash_storage();
|
254 |
$converter->drop_stash_storage();
|
| Línea 255... |
Línea 255... |
| 255 |
}
|
255 |
}
|
| 256 |
|
256 |
|
| Línea 257... |
Línea 257... |
| 257 |
public function test_get_nextid() {
|
257 |
public function test_get_nextid(): void {
|
| Línea 258... |
Línea 258... |
| 258 |
$this->resetAfterTest(true);
|
258 |
$this->resetAfterTest(true);
|
| Línea 266... |
Línea 266... |
| 266 |
$this->assertTrue(0 < $id1);
|
266 |
$this->assertTrue(0 < $id1);
|
| 267 |
$this->assertTrue($id1 < $id2);
|
267 |
$this->assertTrue($id1 < $id2);
|
| 268 |
$this->assertTrue($id2 < $id3);
|
268 |
$this->assertTrue($id2 < $id3);
|
| 269 |
}
|
269 |
}
|
| Línea 270... |
Línea 270... |
| 270 |
|
270 |
|
| 271 |
public function test_migrate_file() {
|
271 |
public function test_migrate_file(): void {
|
| Línea 272... |
Línea 272... |
| 272 |
$this->resetAfterTest(true);
|
272 |
$this->resetAfterTest(true);
|
| 273 |
|
273 |
|
| 274 |
// set-up the file manager
|
274 |
// set-up the file manager
|
| Línea 319... |
Línea 319... |
| 319 |
$fileman->reset_fileids();
|
319 |
$fileman->reset_fileids();
|
| 320 |
$this->assertTrue(count($fileman->get_fileids()) == 0);
|
320 |
$this->assertTrue(count($fileman->get_fileids()) == 0);
|
| 321 |
$converter->drop_stash_storage();
|
321 |
$converter->drop_stash_storage();
|
| 322 |
}
|
322 |
}
|
| Línea 323... |
Línea 323... |
| 323 |
|
323 |
|
| 324 |
public function test_migrate_directory() {
|
324 |
public function test_migrate_directory(): void {
|
| Línea 325... |
Línea 325... |
| 325 |
$this->resetAfterTest(true);
|
325 |
$this->resetAfterTest(true);
|
| 326 |
|
326 |
|
| 327 |
// Set-up the file manager.
|
327 |
// Set-up the file manager.
|
| Línea 367... |
Línea 367... |
| 367 |
$this->assertEquals($this->iconhash, $files['/sub1/file2.gif']['contenthash']);
|
367 |
$this->assertEquals($this->iconhash, $files['/sub1/file2.gif']['contenthash']);
|
| Línea 368... |
Línea 368... |
| 368 |
|
368 |
|
| 369 |
$converter->drop_stash_storage();
|
369 |
$converter->drop_stash_storage();
|
| Línea 370... |
Línea 370... |
| 370 |
}
|
370 |
}
|
| 371 |
|
371 |
|
| Línea 372... |
Línea 372... |
| 372 |
public function test_migrate_directory_with_trailing_slash() {
|
372 |
public function test_migrate_directory_with_trailing_slash(): void {
|
| 373 |
$this->resetAfterTest(true);
|
373 |
$this->resetAfterTest(true);
|
| 374 |
|
374 |
|
| Línea 385... |
Línea 385... |
| 385 |
$this->assertEquals(2, count($returned)); // One file, one directory.
|
385 |
$this->assertEquals(2, count($returned)); // One file, one directory.
|
| Línea 386... |
Línea 386... |
| 386 |
|
386 |
|
| 387 |
$converter->drop_stash_storage();
|
387 |
$converter->drop_stash_storage();
|
| Línea 388... |
Línea 388... |
| 388 |
}
|
388 |
}
|
| 389 |
|
389 |
|
| 390 |
public function test_convert_path() {
|
390 |
public function test_convert_path(): void {
|
| 391 |
$path = new convert_path('foo_bar', '/ROOT/THINGS/FOO/BAR');
|
391 |
$path = new convert_path('foo_bar', '/ROOT/THINGS/FOO/BAR');
|
| 392 |
$this->assertEquals('foo_bar', $path->get_name());
|
392 |
$this->assertEquals('foo_bar', $path->get_name());
|
| 393 |
$this->assertEquals('/ROOT/THINGS/FOO/BAR', $path->get_path());
|
393 |
$this->assertEquals('/ROOT/THINGS/FOO/BAR', $path->get_path());
|
| 394 |
$this->assertEquals('process_foo_bar', $path->get_processing_method());
|
394 |
$this->assertEquals('process_foo_bar', $path->get_processing_method());
|
| 395 |
$this->assertEquals('on_foo_bar_start', $path->get_start_method());
|
395 |
$this->assertEquals('on_foo_bar_start', $path->get_start_method());
|
| Línea 396... |
Línea 396... |
| 396 |
$this->assertEquals('on_foo_bar_end', $path->get_end_method());
|
396 |
$this->assertEquals('on_foo_bar_end', $path->get_end_method());
|
| 397 |
}
|
397 |
}
|
| 398 |
|
398 |
|
| 399 |
public function test_convert_path_implicit_recipes() {
|
399 |
public function test_convert_path_implicit_recipes(): void {
|
| 400 |
$path = new convert_path('foo_bar', '/ROOT/THINGS/FOO/BAR');
|
400 |
$path = new convert_path('foo_bar', '/ROOT/THINGS/FOO/BAR');
|
| 401 |
$data = array(
|
401 |
$data = array(
|
| Línea 411... |
Línea 411... |
| 411 |
$this->assertEquals('stronk7', $data['eloy']);
|
411 |
$this->assertEquals('stronk7', $data['eloy']);
|
| 412 |
$this->assertEquals('moodler', $data['martin']);
|
412 |
$this->assertEquals('moodler', $data['martin']);
|
| 413 |
$this->assertSame(null, $data['empty']);
|
413 |
$this->assertSame(null, $data['empty']);
|
| 414 |
}
|
414 |
}
|
| Línea 415... |
Línea 415... |
| 415 |
|
415 |
|
| 416 |
public function test_convert_path_explicit_recipes() {
|
416 |
public function test_convert_path_explicit_recipes(): void {
|
| 417 |
$path = new convert_path(
|
417 |
$path = new convert_path(
|
| 418 |
'foo_bar', '/ROOT/THINGS/FOO/BAR',
|
418 |
'foo_bar', '/ROOT/THINGS/FOO/BAR',
|
| 419 |
array(
|
419 |
array(
|
| 420 |
'newfields' => array(
|
420 |
'newfields' => array(
|
| Línea 444... |
Línea 444... |
| 444 |
$this->assertEquals('mudrd8mz', $data['david']);
|
444 |
$this->assertEquals('mudrd8mz', $data['david']);
|
| 445 |
$this->assertEquals('skodak', $data['petr']);
|
445 |
$this->assertEquals('skodak', $data['petr']);
|
| 446 |
$this->assertSame(null, $data['nothing']);
|
446 |
$this->assertSame(null, $data['nothing']);
|
| 447 |
}
|
447 |
}
|
| Línea 448... |
Línea 448... |
| 448 |
|
448 |
|
| 449 |
public function test_grouped_data_on_nongrouped_convert_path() {
|
449 |
public function test_grouped_data_on_nongrouped_convert_path(): void {
|
| 450 |
// prepare some grouped data
|
450 |
// prepare some grouped data
|
| 451 |
$data = array(
|
451 |
$data = array(
|
| 452 |
'ID' => 77,
|
452 |
'ID' => 77,
|
| 453 |
'NAME' => 'Pale lagers',
|
453 |
'NAME' => 'Pale lagers',
|
| Línea 473... |
Línea 473... |
| 473 |
// an attempt to apply recipes throws exception because we do not expect grouped data
|
473 |
// an attempt to apply recipes throws exception because we do not expect grouped data
|
| 474 |
$this->expectException(convert_path_exception::class);
|
474 |
$this->expectException(convert_path_exception::class);
|
| 475 |
$data = $path->apply_recipes($data);
|
475 |
$data = $path->apply_recipes($data);
|
| 476 |
}
|
476 |
}
|
| Línea 477... |
Línea 477... |
| 477 |
|
477 |
|
| 478 |
public function test_grouped_convert_path_with_recipes() {
|
478 |
public function test_grouped_convert_path_with_recipes(): void {
|
| 479 |
// prepare some grouped data
|
479 |
// prepare some grouped data
|
| 480 |
$data = array(
|
480 |
$data = array(
|
| 481 |
'ID' => 77,
|
481 |
'ID' => 77,
|
| 482 |
'NAME' => 'Pale lagers',
|
482 |
'NAME' => 'Pale lagers',
|
| Línea 511... |
Línea 511... |
| 511 |
// beer-style name ('Pale lagers') and beer name ('Pilsner Urquell')
|
511 |
// beer-style name ('Pale lagers') and beer name ('Pilsner Urquell')
|
| 512 |
)
|
512 |
)
|
| 513 |
), true);
|
513 |
), true);
|
| 514 |
}
|
514 |
}
|
| Línea 515... |
Línea 515... |
| 515 |
|
515 |
|
| Línea 516... |
Línea 516... |
| 516 |
public function test_referenced_course_files() {
|
516 |
public function test_referenced_course_files(): void {
|
| 517 |
|
517 |
|
| 518 |
$text = 'This is a text containing links to file.php
|
518 |
$text = 'This is a text containing links to file.php
|
| 519 |
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 />
|
519 |
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 />
|
| Línea 533... |
Línea 533... |
| 533 |
<div><a href=\'$@FILEPHP@$/../../../../../../../../../../../../../../../etc/passwd\'>download passwords</a></div>
|
533 |
<div><a href=\'$@FILEPHP@$/../../../../../../../../../../../../../../../etc/passwd\'>download passwords</a></div>
|
| 534 |
<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>
|
534 |
<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>
|
| 535 |
<br /><a href=\'$@FILEPHP@$$@SLASH@$MANUAL.DOC$@FORCEDOWNLOAD@$\'>download manual</a><br />');
|
535 |
<br /><a href=\'$@FILEPHP@$$@SLASH@$MANUAL.DOC$@FORCEDOWNLOAD@$\'>download manual</a><br />');
|
| 536 |
}
|
536 |
}
|
| Línea 537... |
Línea 537... |
| 537 |
|
537 |
|
| Línea 538... |
Línea 538... |
| 538 |
public function test_referenced_files_urlencoded() {
|
538 |
public function test_referenced_files_urlencoded(): void {
|
| 539 |
|
539 |
|
| 540 |
$text = 'This is a text containing links to file.php
|
540 |
$text = 'This is a text containing links to file.php
|
| 541 |
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 />
|
541 |
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 />
|
| Línea 560... |
Línea 560... |
| 560 |
<a href="@@PLUGINFILE@@/illegal%20pics%2Bmovies/romeo%2Bjuliet.avi">Download the full AVI for free! (none encoded)</a>
|
560 |
<a href="@@PLUGINFILE@@/illegal%20pics%2Bmovies/romeo%2Bjuliet.avi">Download the full AVI for free! (none encoded)</a>
|
| 561 |
<a href="$@FILEPHP@$$@SLASH@$illegal%20pics+movies$@SLASH@$romeo+juliet.avi">Download the full AVI for free! (only space encoded)</a>
|
561 |
<a href="$@FILEPHP@$$@SLASH@$illegal%20pics+movies$@SLASH@$romeo+juliet.avi">Download the full AVI for free! (only space encoded)</a>
|
| 562 |
<a href="$@FILEPHP@$$@SLASH@$illegal pics%2Bmovies$@SLASH@$romeo%2Bjuliet.avi">Download the full AVI for free! (only plus)</a>', $text);
|
562 |
<a href="$@FILEPHP@$$@SLASH@$illegal pics%2Bmovies$@SLASH@$romeo%2Bjuliet.avi">Download the full AVI for free! (only plus)</a>', $text);
|
| 563 |
}
|
563 |
}
|
| Línea 564... |
Línea 564... |
| 564 |
|
564 |
|
| 565 |
public function test_question_bank_conversion() {
|
565 |
public function test_question_bank_conversion(): void {
|
| Línea 566... |
Línea 566... |
| 566 |
global $CFG;
|
566 |
global $CFG;
|
| Línea 567... |
Línea 567... |
| 567 |
|
567 |
|
| Línea 573... |
Línea 573... |
| 573 |
);
|
573 |
);
|
| 574 |
$converter = convert_factory::get_converter('moodle1', $this->tempdir);
|
574 |
$converter = convert_factory::get_converter('moodle1', $this->tempdir);
|
| 575 |
$converter->convert();
|
575 |
$converter->convert();
|
| 576 |
}
|
576 |
}
|
| Línea 577... |
Línea 577... |
| 577 |
|
577 |
|
| 578 |
public function test_convert_run_convert() {
|
578 |
public function test_convert_run_convert(): void {
|
| 579 |
$this->resetAfterTest(true);
|
579 |
$this->resetAfterTest(true);
|
| 580 |
$converter = convert_factory::get_converter('moodle1', $this->tempdir);
|
580 |
$converter = convert_factory::get_converter('moodle1', $this->tempdir);
|
| 581 |
$converter->convert();
|
581 |
$converter->convert();
|
| Línea 582... |
Línea 582... |
| 582 |
}
|
582 |
}
|
| 583 |
|
583 |
|
| 584 |
public function test_inforef_manager() {
|
584 |
public function test_inforef_manager(): void {
|
| 585 |
$converter = convert_factory::get_converter('moodle1', $this->tempdir);
|
585 |
$converter = convert_factory::get_converter('moodle1', $this->tempdir);
|
| 586 |
$inforef = $converter->get_inforef_manager('unittest');
|
586 |
$inforef = $converter->get_inforef_manager('unittest');
|
| 587 |
$inforef->add_ref('file', 45);
|
587 |
$inforef->add_ref('file', 45);
|