Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

External course functions unit tests

Copyright: 2012 Jerome Mouneyrac
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 3780 lines (182 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

core_course_externallib_testcase:: (60 methods):
  setUp()
  test_create_categories()
  test_delete_categories()
  test_get_categories()
  test_update_categories()
  test_update_categories_moving()
  test_create_course_numsections()
  test_create_courses()
  course_empty_field_provider()
  test_create_courses_empty_field()
  test_update_courses_empty_field()
  test_delete_courses()
  test_get_courses()
  test_get_courses_customfields()
  test_get_courses_without_capability()
  test_search_courses()
  test_search_courses_customfields()
  prepare_get_course_contents_test()
  test_get_course_contents()
  test_get_course_contents_student()
  test_get_course_contents_excluding_modules()
  test_get_course_contents_excluding_contents()
  test_get_course_contents_section_number()
  test_get_course_contents_cmid()
  test_get_course_contents_section_cmid()
  test_get_course_contents_modname()
  test_get_course_contents_modid()
  test_get_course_contents_completion_manual()
  test_get_course_contents_completion_auto()
  test_get_course_contents_including_mimetype()
  test_get_course_contents_contentsinfo()
  test_get_course_contents_hiddensections()
  test_duplicate_course()
  test_update_courses()
  test_delete_modules()
  test_import_course_empty()
  test_import_course_filled()
  test_import_course_blocksonly()
  test_import_course_deletecontent()
  test_import_course_invalid_deletecontent_option()
  test_view_course()
  test_get_course_module()
  test_get_course_module_by_instance()
  test_get_user_navigation_options()
  test_get_user_administration_options()
  test_get_courses_by_field()
  test_get_courses_by_field_customfields()
  test_get_courses_by_field_invalid_field()
  test_get_courses_by_field_invalid_courses()
  test_get_courses_by_field_invalid_theme_and_lang()
  test_check_updates()
  get_get_enrolled_courses_by_timeline_classification_test_cases()
  test_get_enrolled_courses_by_timeline_classification()
  test_get_recent_courses()
  test_get_enrolled_users_by_cmid()
  test_add_content_item_to_user_favourites()
  test_remove_content_item_from_user_favourites()
  test_get_course_content_items()
  test_get_course_content_items_no_permission_to_manage()
  test_toggle_activity_recommendation()


Class: core_course_externallib_testcase  - X-Ref

External course functions unit tests

setUp()   X-Ref
Tests set up


test_create_categories()   X-Ref
Test create_categories


test_delete_categories()   X-Ref
Test delete categories


test_get_categories()   X-Ref
Test get categories


test_update_categories()   X-Ref
Test update_categories


test_update_categories_moving()   X-Ref
Test update_categories method for moving categories


test_create_course_numsections()   X-Ref
Test create_courses numsections


test_create_courses()   X-Ref
Test create_courses


course_empty_field_provider()   X-Ref
Data provider for testing empty fields produce expected exceptions

return: array

test_create_courses_empty_field(array $course, string $expectedemptyfield)   X-Ref
Test creating courses with empty fields throws an exception

param: array $course
param: string $expectedemptyfield

test_update_courses_empty_field(array $course, string $expectedemptyfield)   X-Ref
Test updating courses with empty fields returns warnings

param: array $course
param: string $expectedemptyfield

test_delete_courses()   X-Ref
Test delete_courses


test_get_courses()   X-Ref
Test get_courses


test_get_courses_customfields()   X-Ref
Test retrieving courses returns custom field data


test_get_courses_without_capability()   X-Ref
Test get_courses without capability


test_search_courses()   X-Ref
Test search_courses


test_search_courses_customfields()   X-Ref
Test searching for courses returns custom field data


prepare_get_course_contents_test()   X-Ref
Create a course with contents

return: array A list with the course object and course modules objects

test_get_course_contents()   X-Ref
Test get_course_contents


test_get_course_contents_student()   X-Ref
Test get_course_contents as student


test_get_course_contents_excluding_modules()   X-Ref
Test get_course_contents excluding modules


test_get_course_contents_excluding_contents()   X-Ref
Test get_course_contents excluding contents


test_get_course_contents_section_number()   X-Ref
Test get_course_contents filtering by section number


test_get_course_contents_cmid()   X-Ref
Test get_course_contents filtering by cmid


test_get_course_contents_section_cmid()   X-Ref
Test get_course_contents filtering by cmid and section


test_get_course_contents_modname()   X-Ref
Test get_course_contents filtering by modname


test_get_course_contents_modid()   X-Ref
Test get_course_contents filtering by modname


test_get_course_contents_completion_manual()   X-Ref
Test get course contents completion manual


test_get_course_contents_completion_auto()   X-Ref
Test get course contents completion auto


test_get_course_contents_including_mimetype()   X-Ref
Test mimetype is returned for resources with showtype set.


test_get_course_contents_contentsinfo()   X-Ref
Test contents info is returned.


test_get_course_contents_hiddensections()   X-Ref
Test get_course_contents when hidden sections are displayed.


test_duplicate_course()   X-Ref
Test duplicate_course


test_update_courses()   X-Ref
Test update_courses


test_delete_modules()   X-Ref
Test delete course_module.


test_import_course_empty()   X-Ref
Test import_course into an empty course


test_import_course_filled()   X-Ref
Test import_course into an filled course


test_import_course_blocksonly()   X-Ref
Test import_course with only blocks set to backup


test_import_course_deletecontent()   X-Ref
Test import_course into an filled course, deleting content.


test_import_course_invalid_deletecontent_option()   X-Ref
Ensure import_course handles incorrect deletecontent option correctly.


test_view_course()   X-Ref
Test view_course function


test_get_course_module()   X-Ref
Test get_course_module


test_get_course_module_by_instance()   X-Ref
Test get_course_module_by_instance


test_get_user_navigation_options()   X-Ref
Test get_user_navigation_options


test_get_user_administration_options()   X-Ref
Test get_user_administration_options


test_get_courses_by_field()   X-Ref
Test get_courses_by_fields


test_get_courses_by_field_customfields()   X-Ref
Test retrieving courses by field returns custom field data


test_get_courses_by_field_invalid_field()   X-Ref
No description

test_get_courses_by_field_invalid_courses()   X-Ref
No description

test_get_courses_by_field_invalid_theme_and_lang()   X-Ref
Test get_courses_by_field_invalid_theme_and_lang


test_check_updates()   X-Ref
No description

get_get_enrolled_courses_by_timeline_classification_test_cases()   X-Ref
Test cases for the get_enrolled_courses_by_timeline_classification test.


test_get_enrolled_courses_by_timeline_classification($coursedata,$classification,$limit,$offset,$sort,$expectedcourses,$expectednextoffset,$expectedexception = null)   X-Ref
Test the get_enrolled_courses_by_timeline_classification function.

param: array $coursedata Courses to create
param: string $classification Timeline classification
param: int $limit Maximum number of results
param: int $offset Offset the unfiltered courses result set by this amount
param: string $sort sort the courses
param: array $expectedcourses Expected courses in result
param: int $expectednextoffset Expected next offset value in result
param: string|null $expectedexception Expected exception string

test_get_recent_courses()   X-Ref
Test the get_recent_courses function.


test_get_enrolled_users_by_cmid()   X-Ref
Test get enrolled users by cmid function.


test_add_content_item_to_user_favourites()   X-Ref
Verify that content items can be added to user favourites.


test_remove_content_item_from_user_favourites()   X-Ref
Verify that content items can be removed from user favourites.


test_get_course_content_items()   X-Ref
Test the web service returning course content items for inclusion in activity choosers, etc.


test_get_course_content_items_no_permission_to_manage()   X-Ref
Test the web service returning course content items, specifically in case where the user can't manage activities.


test_toggle_activity_recommendation()   X-Ref
Test toggling the recommendation of an activity.