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: modinfolib_test  - X-Ref

Unit tests for lib/modinfolib.php.

test_section_info_properties()   X-Ref
No description

test_cm_info_properties()   X-Ref
No description

test_matching_cacherev()   X-Ref
No description

test_course_modinfo_properties()   X-Ref
No description

test_is_user_access_restricted_by_capability()   X-Ref
No description

test_cm_info_get_course_module_record()   X-Ref
Tests for function cm_info::get_course_module_record()


test_availability_property()   X-Ref
Tests the availability property that has been added to course modules
and sections (just to see that it is correctly saved and accessed).


test_get_groups()   X-Ref
Tests for get_groups() method.


test_create()   X-Ref
Tests the function for constructing a cm_info from mixed data.


test_get_course_and_cm_from_cmid()   X-Ref
Tests function for getting $course and $cm at once quickly from modinfo
based on cmid or cm record.


test_get_course_and_cm_from_instance()   X-Ref
Tests function for getting $course and $cm at once quickly from modinfo
based on instance id or record.


test_get_section_info_by_id(int $sectionnum,int $strictness = IGNORE_MISSING,bool $expectnull = false,bool $expectexception = false)   X-Ref
Test test_get_section_info_by_id method

param: int $sectionnum the section number
param: int $strictness the search strict mode
param: bool $expectnull if the function will return a null
param: bool $expectexception if the function will throw an exception

get_section_info_by_id_provider()   X-Ref
Data provider for test_get_section_info_by_id().

return: array

test_purge_section_cache_by_id()   X-Ref
Test purge_section_cache_by_id method

return: void

test_section_cache_by_number()   X-Ref
Test purge_section_cache_by_number method

return: void

test_purge_course_module()   X-Ref
Purge a single course module from the cache.

return: void

test_purge_multiple_course_modules()   X-Ref
Purge a multiple course modules from the cache.

return: void

test_invalid_course_module_id()   X-Ref
Test get_cm() method to output course module id in the exception text.

return: void

test_get_modinfo_with_newer_version()   X-Ref
Tests that if the modinfo cache returns a newer-than-expected version, Moodle won't rebuild
it.

This is important to avoid wasted time/effort and poor performance, for example in cases
where multiple requests are accessing the course.

Certain cases could be particularly bad if this test fails. For example, if using clustered
databases where there is a 100ms delay between updates to the course table being available
to all users (but no such delay on the cache infrastructure), then during that 100ms, every
request that calls get_fast_modinfo and uses the read-only database will rebuild the course
cache. Since these will then create a still-newer version, future requests for the next
100ms will also rebuild it again... etc.