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]

Completion tests.

Copyright: 2008 Sam Marshall
Copyright: 2013 Frédéric Massart
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 1523 lines (64 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes


Class: completionlib_test  - X-Ref

Completion tests.

mock_setup()   X-Ref
No description

setup_data()   X-Ref
Create course with user and activities.


assertEquals($expected, $actual, string $message = '', float $delta = 0, int $maxDepth = 10,bool $canonicalize = false, bool $ignoreCase = false)   X-Ref
Asserts that two variables are equal.

param: mixed   $expected
param: mixed   $actual
param: string  $message
param: float   $delta
param: integer $maxDepth
param: boolean $canonicalize
param: boolean $ignoreCase

test_is_enabled()   X-Ref


test_update_state()   X-Ref


internal_get_state_provider()   X-Ref
Data provider for test_internal_get_state().

return: array[]

test_internal_get_state(int $completionview, int $completionusegrade, string $unsetfield, int $expectedstate)   X-Ref
Test for completion_info::get_state().

param: int $completionview
param: int $completionusegrade
param: string $unsetfield
param: int $expectedstate

test_internal_get_state_with_different_user()   X-Ref
Covers the case where internal_get_state() is being called for a user different from the logged in user.


test_internal_get_state_with_custom_completion()   X-Ref
Test for internal_get_state() for an activity that supports custom completion.


test_set_module_viewed()   X-Ref


test_count_user_data()   X-Ref


test_delete_all_state()   X-Ref


test_reset_all_state()   X-Ref


get_data_provider()   X-Ref
Data provider for test_get_data().

return: array[]

test_get_data(bool $wholecourse, bool $sameuser, bool $hasrecord, int $completion)   X-Ref
Tests for completion_info::get_data().

param: bool $wholecourse Whole course parameter for get_data().
param: bool $sameuser Whether the user calling get_data() is the user itself.
param: bool $hasrecord Whether to create a course_modules_completion record.
param: int $completion The completion state expected.

test_get_data_successive_calls()   X-Ref


test_get_other_cm_completion_data()   X-Ref
Tests for completion_info::get_other_cm_completion_data().


test_internal_set_data()   X-Ref


test_get_progress_all_few()   X-Ref


test_get_progress_all_lots()   X-Ref


test_inform_grade_changed()   X-Ref


test_internal_get_grade_state()   X-Ref


test_get_activities()   X-Ref


test_has_activities()   X-Ref


test_course_delete_prerequisite()   X-Ref
Test that data is cleaned up when we delete courses that are set as completion criteria for other courses


test_course_module_completion_updated_event()   X-Ref
Test course module completion update event.


test_course_completed_event()   X-Ref
Test course completed event.


test_course_completed_message()   X-Ref
Test course completed message.


test_course_completion_updated_event()   X-Ref
Test course completed event.


test_completion_can_view_data()   X-Ref


get_grade_completion_provider()   X-Ref
Data provider for test_get_grade_completion().

return: array[]

test_get_grade_completion(bool $completionusegrade, bool $hasgrade, ?int $passinggrade,?string $expectedexception, ?int $expectedresult)   X-Ref
Test for \completion_info::get_grade_completion().

param: bool $completionusegrade Whether the test activity has grade completion requirement.
param: bool $hasgrade Whether to set grade for the user in this activity.
param: int|null $passinggrade Passing grade to set for the test activity.
param: string|null $expectedexception Expected exception.
param: int|null $expectedresult The expected completion status.

test_get_grade_completion_without_grade_item()   X-Ref
Test the return value for cases when the activity module does not have associated grade_item.


Class: core_completionlib_fake_recordset  - X-Ref

__construct($values)   X-Ref
No description

current()   X-Ref
No description

key()   X-Ref
No description

next()   X-Ref
No description

rewind()   X-Ref
No description

valid()   X-Ref
No description

close()   X-Ref
No description

was_closed()   X-Ref
No description