MDL-23545 question: XML import/export add category description
This commit is contained in:
@@ -1583,4 +1583,40 @@ END;
|
||||
$this->assertEquals('/myfolder/', $file->filepath);
|
||||
$this->assertEquals(6, $file->size);
|
||||
}
|
||||
|
||||
public function test_create_dummy_question() {
|
||||
|
||||
$testobject = new mock_qformat_xml();
|
||||
$categoryname = 'name1';
|
||||
$categoryinfo = new stdClass();
|
||||
$categoryinfo->info = 'info1';
|
||||
$categoryinfo->infoformat = 'infoformat1';
|
||||
$dummyquestion = $testobject->mock_create_dummy_question_representing_category($categoryname, $categoryinfo);
|
||||
|
||||
$this->assertEquals('category', $dummyquestion->qtype);
|
||||
$this->assertEquals($categoryname, $dummyquestion->category);
|
||||
$this->assertEquals($categoryinfo->info, $dummyquestion->info);
|
||||
$this->assertEquals($categoryinfo->infoformat, $dummyquestion->infoformat);
|
||||
$this->assertEquals('Switch category to ' . $categoryname, $dummyquestion->name);
|
||||
$this->assertEquals(0, $dummyquestion->id);
|
||||
$this->assertEquals('', $dummyquestion->questiontextformat);
|
||||
$this->assertEquals(0, $dummyquestion->contextid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class mock_qformat_xml exists only to enable testing of the create dummy question category.
|
||||
* @package qformat_xml
|
||||
* @copyright 2018 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class mock_qformat_xml extends qformat_xml {
|
||||
/**
|
||||
* Make public an otherwise protected function.
|
||||
* @param string $categoryname the name of the category
|
||||
* @param object $categoryinfo description of the category
|
||||
*/
|
||||
public function mock_create_dummy_question_representing_category(string $categoryname, $categoryinfo) {
|
||||
return $this->create_dummy_question_representing_category($categoryname, $categoryinfo);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user