Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403] [Versions 39 and 310]
Question external functions tests.
Copyright: | 2016 Pau Ferrer <pau@moodle.com> |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 838 lines (35 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
core_question_external_testcase:: (22 methods):
setUp()
test_core_question_update_flag()
test_submit_tags_form_incorrect_question_id()
test_submit_tags_form_incorrect_context_id()
test_submit_tags_form_tags_disabled()
test_submit_tags_form_no_tag_permissions()
test_submit_tags_form_tagmine_permission_non_owner_question()
get_submit_tags_form_testcases()
test_submit_tags_form_context_combinations()
generate_encoded_submit_tags_form_string()
create_user_can_tag()
get_random_question_summaries_test_cases()
test_get_random_question_summaries_variations()
test_get_random_question_summaries_invalid_category_id_param()
test_get_random_question_summaries_invalid_includesubcategories_param()
test_get_random_question_summaries_invalid_tagids_param()
test_get_random_question_summaries_invalid_context()
test_get_random_question_summaries_restricted_context()
test_get_random_question_summaries_formats_returned_questions()
test_get_random_question_summaries_with_limit_and_offset()
test_get_random_question_summaries_without_capability()
create_category_and_questions()
Class: core_question_external_testcase - X-Ref
Question external functions testssetUp() X-Ref |
Set up for every test |
test_core_question_update_flag() X-Ref |
Test update question flag |
test_submit_tags_form_incorrect_question_id() X-Ref |
submit_tags_form should throw an exception when the question id doesn't match a question. |
test_submit_tags_form_incorrect_context_id() X-Ref |
submit_tags_form should throw an exception when the context id doesn't match a context. |
test_submit_tags_form_tags_disabled() X-Ref |
submit_tags_form should return false when tags are disabled. |
test_submit_tags_form_no_tag_permissions() X-Ref |
submit_tags_form should return false if the user does not have any capability to tag the question. |
test_submit_tags_form_tagmine_permission_non_owner_question() X-Ref |
submit_tags_form should return false if the user only has the capability to tag their own questions and the question is not theirs. |
get_submit_tags_form_testcases() X-Ref |
Data provided for the submit_tags_form test to check that course tags are only created in the correct editing and question context combinations. return: array Test cases |
test_submit_tags_form_context_combinations($editingcontext,$questioncontext,$questiontags,$coursetags,$expectcoursetags) X-Ref |
Tests that submit_tags_form only creates course tags when the correct combination of editing context and question context is provided. Course tags can only be set on a course category or system context question that is being editing in a course context. param: string $editingcontext The type of the context the question is being edited in param: string $questioncontext The type of the context the question belongs to param: string[] $questiontags The tag names to set as question tags param: string[] $coursetags The tag names to set as course tags param: bool $expectcoursetags If the given course tags should have been set or not |
generate_encoded_submit_tags_form_string($question, $questioncategory,$questioncontext, $tags = [], $coursetags = []) X-Ref |
Build the encoded form data expected by the submit_tags_form external function. param: stdClass $question The question record param: stdClass $questioncategory The question category record param: context $questioncontext Context for the question category param: array $tags A list of tag names for the question param: array $coursetags A list of course tag names for the question return: string HTML encoded string of the data |
create_user_can_tag($course) X-Ref |
Create a user, enrol them in the course, and give them the capability to tag all questions in the system context. param: stdClass $course The course record to enrol in return: stdClass The user record |
get_random_question_summaries_test_cases() X-Ref |
Data provider for the get_random_question_summaries test. |
test_get_random_question_summaries_variations($categoryindex,$includesubcategories,$usetagnames,$expectedquestionindexes) X-Ref |
Test the get_random_question_summaries function with various parameter combinations. This function creates a data set as follows: Category: cat1 Question: cat1q1 Tags: 'cat1', 'foo' Question: cat1q2 Category: cat2 Question: cat2q1 Tags: 'cat2', 'foo' Question: cat2q2 Category: subcat Question: subcatq1 Tags: 'subcat', 'foo' Question: subcatq2 Parent: cat1 Category: emptycat param: string $categoryindex The named index for the category to use param: bool $includesubcategories If the search should include subcategories param: string[] $usetagnames The tag names to include in the search param: string[] $expectedquestionindexes The questions expected in the result |
test_get_random_question_summaries_invalid_category_id_param() X-Ref |
get_random_question_summaries should throw an invalid_parameter_exception if not given an integer for the category id. |
test_get_random_question_summaries_invalid_includesubcategories_param() X-Ref |
get_random_question_summaries should throw an invalid_parameter_exception if not given a boolean for the $includesubcategories parameter. |
test_get_random_question_summaries_invalid_tagids_param() X-Ref |
get_random_question_summaries should throw an invalid_parameter_exception if not given an array of integers for the tag ids parameter. |
test_get_random_question_summaries_invalid_context() X-Ref |
get_random_question_summaries should throw an invalid_parameter_exception if not given a context. |
test_get_random_question_summaries_restricted_context() X-Ref |
get_random_question_summaries should throw an restricted_context_exception if the given context is outside of the set of restricted contexts the user is allowed to call external functions in. |
test_get_random_question_summaries_formats_returned_questions() X-Ref |
get_random_question_summaries should return a question that is formatted correctly. |
test_get_random_question_summaries_with_limit_and_offset() X-Ref |
get_random_question_summaries should allow limiting and offsetting of the result set. |
test_get_random_question_summaries_without_capability() X-Ref |
get_random_question_summaries should throw an exception if the user doesn't have the capability to use the questions in the requested category. |
create_category_and_questions($questioncount, $tagnames = [], $parentcategory = null) X-Ref |
Create a question category and create questions in that category. Tag the first question in each category with the given tags. param: int $questioncount How many questions to create. param: string[] $tagnames The list of tags to use. param: stdClass|null $parentcategory The category to set as the parent of the created category. return: array The category and questions. |