Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 311 and 400] [Versions 400 and 403]

Contains unit tests for core_completion/cm_completion_details.

Copyright: 2021 Jun Pataleta <jun@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 462 lines (19 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: cm_completion_details_test  - X-Ref

Class for unit testing core_completion/cm_completion_details.

setup_data(?int $completion, array $completionoptions = [],object $mockcompletiondata = null, $modname = 'somenonexistentmod')   X-Ref
Fetches a mocked cm_completion_details instance.

return: cm_completion_details
param: int|null $completion The completion tracking mode for the module.
param: array $completionoptions Completion options (e.g. completionview, completionusegrade, etc.)
param: object $mockcompletiondata Mock data to be returned by get_data.
param: string $modname The modname to set in the cm if a specific one is required.

has_completion_provider()   X-Ref
Provides data for test_has_completion().

return: array[]

test_has_completion(int $completion, bool $expectedresult)   X-Ref
Test for has_completion().

param: int $completion The completion tracking mode.
param: bool $expectedresult Expected result.

is_automatic_provider()   X-Ref
Provides data for test_is_automatic().

return: array[]

test_is_automatic(int $completion, bool $expectedresult)   X-Ref
Test for is_available().

param: int $completion The completion tracking mode.
param: bool $expectedresult Expected result.

overall_completion_provider()   X-Ref
Data provider for test_get_overall_completion().

return: array[]

test_get_overall_completion(int $state)   X-Ref
Test for get_overall_completion().

param: int $state

get_details_provider()   X-Ref
Data provider for test_get_details().

return: array[]

test_get_details(int $completion, ?int $completionview,?int $completiongrade, ?int $completionpassgrade, array $expecteddetails)   X-Ref
Test for \core_completion\cm_completion_details::get_details().

param: int $completion The completion tracking mode.
param: int|null $completionview Completion status of the "view" completion condition.
param: int|null $completiongrade Completion status of the "must receive grade" completion condition.
param: int|null $completionpassgrade Completion status of the "must receive passing grade" completion condition.
param: array $expecteddetails Expected completion details returned by get_details().

get_details_custom_order_provider()   X-Ref
Data provider for test_get_details_custom_order().

return: array[]

test_get_details_custom_order(bool $completionview, bool $completiongrade, array $customcompletionrules,string $modname, array $expectedorder)   X-Ref
Test custom sort order is functioning in \core_completion\cm_completion_details::get_details().

param: bool $completionview Completion status of the "view" completion condition.
param: bool $completiongrade Completion status of the "must receive grade" completion condition.
param: array $customcompletionrules Custom completion requirements, along with their values.
param: string $modname The name of the module having data fetched.
param: array $expectedorder The expected order of completion conditions returned about the module.