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.

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

(no description)

File Size: 2083 lines (87 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

completionlib_test:: (43 methods):
  mock_setup()
  setup_data()
  assertEquals()
  test_is_enabled()
  test_update_state()
  internal_get_state_provider()
  test_internal_get_state()
  internal_get_state_with_grade_criteria_provider()
  test_internal_get_state_with_grade_criteria()
  test_internal_get_state_with_different_user()
  test_internal_get_state_with_custom_completion()
  test_set_module_viewed()
  test_count_user_data()
  test_delete_all_state()
  test_reset_all_state()
  get_data_provider()
  test_get_data()
  test_get_data_successive_calls()
  test_get_completion_data()
  test_get_other_cm_completion_data()
  test_internal_set_data()
  test_get_progress_all_few()
  test_get_progress_all_lots()
  test_inform_grade_changed()
  test_internal_get_grade_state()
  test_get_activities()
  test_has_activities()
  test_course_delete_prerequisite()
  test_course_module_completion_updated_event()
  test_course_completed_event()
  test_course_completed_message()
  test_course_completion_updated_event()
  test_completion_can_view_data()
  get_grade_completion_provider()
  test_get_grade_completion()
  test_get_grade_completion_without_grade_item()
  test_aggregate_completions()
  test_save()
  test_mark_enrolled()
  test_mark_inprogress()
  test_mark_complete()
  test_criteria_mark_complete()
  test_course_reset_completion()

core_completionlib_fake_recordset:: (8 methods):
  __construct()
  current()
  key()
  next()
  rewind()
  valid()
  close()
  was_closed()


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

internal_get_state_with_grade_criteria_provider()   X-Ref
Provider for the test_internal_get_state_with_grade_criteria.

return: array

test_internal_get_state_with_grade_criteria(array $completioncriteria, ?int $studentgrade, int $expectedstate)   X-Ref
Tests that the right completion state is being set based on the grade criteria.

param: array $completioncriteria The completion criteria to use
param: int|null $studentgrade Grade to assign to student
param: int $expectedstate Expected completion state

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_completion_data()   X-Ref
Tests for get_completion_data().


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.


test_aggregate_completions()   X-Ref
Test for aggregate_completions().


test_save()   X-Ref
Test for completion_completion::_save().


test_mark_enrolled()   X-Ref
Test for completion_completion::mark_enrolled().


test_mark_inprogress()   X-Ref
Test for completion_completion::mark_inprogress().


test_mark_complete()   X-Ref
Test for completion_completion::mark_complete().


test_criteria_mark_complete()   X-Ref
Test for completion_criteria_completion::mark_complete().


test_course_reset_completion()   X-Ref
Test that data is cleaned when we reset a course completion data


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