From 2726d2a6a436a8bae1a5a8800ba71da166eab492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mudr=C3=A1k?= Date: Mon, 7 Jan 2013 22:20:09 +0100 Subject: [PATCH] MDL-36977 Add more unit tests for moodle1 backup conversion --- backup/converter/moodle1/tests/lib_test.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/backup/converter/moodle1/tests/lib_test.php b/backup/converter/moodle1/tests/lib_test.php index bf4935cdd5f..154b6c88d7c 100644 --- a/backup/converter/moodle1/tests/lib_test.php +++ b/backup/converter/moodle1/tests/lib_test.php @@ -273,6 +273,15 @@ class moodle1_converter_testcase extends advanced_testcase { $fileids = $fileman->get_fileids(); $this->assertEquals(gettype($fileids), 'array'); $this->assertEquals(0, count($fileids)); + // try to migrate an invalid file + $fileman->itemid = 1; + $thrown = false; + try { + $fileman->migrate_file('/../../../../../../../../../../../../../../etc/passwd'); + } catch (moodle1_convert_exception $e) { + $thrown = true; + } + $this->assertTrue($thrown); // migrate a single file $fileman->itemid = 4; $fileman->migrate_file('moddata/unittest/4/icon.gif'); @@ -435,6 +444,8 @@ class moodle1_converter_testcase extends advanced_testcase { $text = 'This is a text containing links to file.php as it is parsed from the backup file.

Newsdownload image
+
download passwords
+
download shadows

download manual
'; $files = moodle1_converter::find_referenced_files($text); @@ -446,6 +457,8 @@ as it is parsed from the backup file.

assertEquals($text, 'This is a text containing links to file.php as it is parsed from the backup file.

Newsdownload image
+
download passwords
+
download shadows

download manual
'); }