Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401]

Unit tests for export/import description (info) for question category in the Moodle XML format.

Copyright: 2014 Nikita Nikitsky, Volgograd State Technical University
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 501 lines (23 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: qformat_xml_import_export_test  - X-Ref

Unit tests for the XML question format import and export.

create_qformat($filename, $course)   X-Ref
Create object qformat_xml for test.

param: string $filename with name for testing file.
param: stdClass $course
return: qformat_xml XML question format object.

assert_same_xml($expectedxml, $xml)   X-Ref
Check xml for compliance.

param: string $expectedxml with correct string.
param: string $xml you want to check.

normalise_xml($xml)   X-Ref
Clean up some XML to remove irrelevant differences, before it is compared.

param: string $xml some XML.
return: string cleaned-up XML.

assert_category_imported($name, $info, $infoformat, $idnumber = null)   X-Ref
Check imported category.

param: string $name imported category name.
param: string $info imported category info field (description of category).
param: int $infoformat imported category info field format.

assert_category_has_parent($catname, $parentname)   X-Ref
Check a question category has a given parent.

param: string $catname Name of the question category
param: string $parentname Name of the parent category

assert_question_in_category($qname, $catname)   X-Ref
Check a question exists in a category.

param: string $qname The name of the question
param: string $catname The name of the category

test_import_category()   X-Ref
Simple check for importing a category with a description.


test_import_nested_categories()   X-Ref
Check importing nested categories.


test_import_nested_categories_with_questions()   X-Ref
Check importing nested categories contain the right questions.


test_import_old_format()   X-Ref
Check import of an old file (without format), for backward compatability.


test_import_categories_in_reverse_order()   X-Ref
Check the import of an xml file where the child category exists before the parent category.


test_export_category()   X-Ref
Simple check for exporting a category.


test_export_nested_categories()   X-Ref
Check exporting nested categories.


test_export_nested_categories_with_questions()   X-Ref
Check exporting nested categories contain the right questions.


test_export_category_with_special_chars()   X-Ref
Simple check for exporting a category.


test_import_broken_multianswer_questions()   X-Ref
Test that bad multianswer questions are not imported.