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.

Class: question_category_object_test  - X-Ref

Unit tests for qbank_managecategories\question_category_object.

setUp()   X-Ref


test_add_category_no_idnumber()   X-Ref
Test creating a category.


test_add_category_set_idnumber_0()   X-Ref
Test creating a category with a tricky idnumber.


test_add_category_try_to_set_duplicate_idnumber()   X-Ref
Trying to add a category with duplicate idnumber blanks it.
(In reality, this would probably get caught by form validation.)


test_update_category()   X-Ref
Test updating a category.


test_update_category_removing_idnumber()   X-Ref
Test updating a category to remove the idnumber.


test_update_category_dont_change_idnumber()   X-Ref
Test updating a category without changing the idnumber.


test_update_category_try_to_set_duplicate_idnumber()   X-Ref
Trying to update a category so its idnumber duplicates idnumber blanks it.
(In reality, this would probably get caught by form validation.)


test_question_category_created()   X-Ref
Test the question category created event.


test_question_category_deleted()   X-Ref
Test the question category deleted event.


test_question_category_updated()   X-Ref
Test the question category updated event.


test_question_category_viewed()   X-Ref
Test the question category viewed event.
There is no external API for viewing the category, so the unit test will simply
create and trigger the event and ensure data is returned as expected.


test_get_real_question_ids_in_category_shortanswer()   X-Ref
Test that get_real_question_ids_in_category() returns question id
of a shortanswer question in a category.


test_get_real_question_ids_in_category_multianswer()   X-Ref
Test that get_real_question_ids_in_category() returns question id
of a multianswer question in a category.


test_get_real_question_ids_in_category_multianswer_two_versions()   X-Ref
Test that get_real_question_ids_in_category() returns question ids
of two versions of a multianswer question in a category.


test_get_real_question_ids_in_category_multianswer_bad_data()   X-Ref
Test that get_real_question_ids_in_category() returns question id
of a multianswer question in a category even if their child questions are
linked to a category that doesn't exist.