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 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

Unit tests for lib.php

Copyright: 2013 Adrian Greeve
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 2013 lines (81 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

lib_test:: (45 methods):
  tearDown()
  test_data_completion()
  test_data_delete_record()
  test_data_comment_created_event()
  test_data_comment_deleted_event()
  test_data_user_can_manage_entry_return_true_with_capability()
  test_data_user_can_manage_entry_return_false_readonly()
  test_data_user_can_manage_entry_return_false_no_record()
  test_data_user_can_manage_entry_return_false_not_owned_record()
  test_data_user_can_manage_entry_return_true_data_no_approval()
  test_data_user_can_manage_entry_return_true_record_unapproved()
  test_data_user_can_manage_entry_return_manageapproved()
  create_user_test_data()
  test_mod_data_rating_can_see_item_ratings()
  test_data_refresh_events()
  data_get_config_provider()
  test_data_get_config()
  data_set_config_provider()
  test_data_set_config()
  test_data_view()
  test_mod_data_get_tagged_records()
  test_mod_data_get_tagged_records_approval()
  test_mod_data_get_tagged_records_time()
  test_mod_data_get_tagged_records_course_enrolment()
  test_mod_data_get_tagged_records_course_groups()
  test_check_updates_since()
  test_data_core_calendar_provide_event_action_in_hidden_section()
  test_data_core_calendar_provide_event_action_for_non_user()
  test_data_core_calendar_provide_event_action_open()
  test_data_core_calendar_provide_event_action_open_for_user()
  test_data_core_calendar_provide_event_action_closed()
  test_data_core_calendar_provide_event_action_closed_for_user()
  test_data_core_calendar_provide_event_action_open_in_future()
  test_data_core_calendar_provide_event_action_open_in_future_for_user()
  test_data_core_calendar_provide_event_action_no_time_specified()
  test_data_core_calendar_provide_event_action_no_time_specified_for_user()
  create_action_event()
  test_mod_data_completion_get_active_rule_descriptions()
  test_mod_data_core_calendar_event_timestart_updated_unknown_event()
  test_mod_data_core_calendar_event_timestart_updated_open_event()
  test_mod_data_core_calendar_event_timestart_updated_close_event()
  test_mod_data_core_calendar_get_valid_event_timestart_range_unknown_event()
  test_mod_data_core_calendar_get_valid_event_timestart_range_open_event()
  test_mod_data_core_calendar_get_valid_event_timestart_range_close_event()
  test_creation_with_no_calendar_capabilities()


Class: lib_test  - X-Ref

Unit tests for lib.php

tearDown()   X-Ref
Tear Down to reset DB.


test_data_completion()   X-Ref
Confirms that completionentries is working
Sets it to 1, confirms that
it is not complete. Inserts a record and
confirms that it is complete.


test_data_delete_record()   X-Ref
No description

test_data_comment_created_event()   X-Ref
Test comment_created event.


test_data_comment_deleted_event()   X-Ref
Test comment_deleted event.


test_data_user_can_manage_entry_return_true_with_capability()   X-Ref
Checks that data_user_can_manage_entry will return true if the user
has the mod/data:manageentries capability.


test_data_user_can_manage_entry_return_false_readonly()   X-Ref
Checks that data_user_can_manage_entry will return false if the data
is set to readonly.


test_data_user_can_manage_entry_return_false_no_record()   X-Ref
Checks that data_user_can_manage_entry will return false if the record
can't be found in the database.


test_data_user_can_manage_entry_return_false_not_owned_record()   X-Ref
Checks that data_user_can_manage_entry will return false if the record
isn't owned by the user.


test_data_user_can_manage_entry_return_true_data_no_approval()   X-Ref
Checks that data_user_can_manage_entry will return true if the data
doesn't require approval.


test_data_user_can_manage_entry_return_true_record_unapproved()   X-Ref
Checks that data_user_can_manage_entry will return true if the record
isn't yet approved.


test_data_user_can_manage_entry_return_manageapproved()   X-Ref
Checks that data_user_can_manage_entry will return the 'manageapproved'
value if the record has already been approved.


create_user_test_data()   X-Ref
Helper method to create a set of test data for data_user_can_manage tests

return: array contains user, course, roleid, module, context and record

test_mod_data_rating_can_see_item_ratings()   X-Ref
Tests for mod_data_rating_can_see_item_ratings().


test_data_refresh_events()   X-Ref
Tests for mod_data_refresh_events.


data_get_config_provider()   X-Ref
Data provider for tests of data_get_config.

return: array

test_data_get_config($funcargs, $expectation)   X-Ref
Tests for data_get_config.

param: array   $funcargs       The args to pass to data_get_config
param: mixed   $expectation    The expected value

data_set_config_provider()   X-Ref
Data provider for tests of data_set_config.

return: array

test_data_set_config($database, $key, $value, $expectupdate, $newconfigvalue)   X-Ref
Tests for data_set_config.

param: object  $database       The example row for the entry
param: string  $key            The config key to set
param: mixed   $value          The value of the key
param: bool    $expectupdate   Whether we expected an update
param: mixed   $newconfigvalue The expected value

test_data_view()   X-Ref
Test data_view

return: void

test_mod_data_get_tagged_records()   X-Ref
No description

test_mod_data_get_tagged_records_approval()   X-Ref
No description

test_mod_data_get_tagged_records_time()   X-Ref
No description

test_mod_data_get_tagged_records_course_enrolment()   X-Ref
No description

test_mod_data_get_tagged_records_course_groups()   X-Ref
No description

test_check_updates_since()   X-Ref
Test check_updates_since callback.


test_data_core_calendar_provide_event_action_in_hidden_section()   X-Ref
No description

test_data_core_calendar_provide_event_action_for_non_user()   X-Ref
No description

test_data_core_calendar_provide_event_action_open()   X-Ref
No description

test_data_core_calendar_provide_event_action_open_for_user()   X-Ref
No description

test_data_core_calendar_provide_event_action_closed()   X-Ref
No description

test_data_core_calendar_provide_event_action_closed_for_user()   X-Ref
No description

test_data_core_calendar_provide_event_action_open_in_future()   X-Ref
No description

test_data_core_calendar_provide_event_action_open_in_future_for_user()   X-Ref
No description

test_data_core_calendar_provide_event_action_no_time_specified()   X-Ref
No description

test_data_core_calendar_provide_event_action_no_time_specified_for_user()   X-Ref
No description

create_action_event($courseid, $instanceid, $eventtype, $timestart = null)   X-Ref
Creates an action event.

param: int $courseid
param: int $instanceid The data id.
param: string $eventtype The event type. eg. DATA_EVENT_TYPE_OPEN.
param: int|null $timestart The start timestamp for the event
return: bool|calendar_event

test_mod_data_completion_get_active_rule_descriptions()   X-Ref
Test the callback responsible for returning the completion rule descriptions.
This function should work given either an instance of the module (cm_info), such as when checking the active rules,
or if passed a stdClass of similar structure, such as when checking the the default completion settings for a mod type.


test_mod_data_core_calendar_event_timestart_updated_unknown_event()   X-Ref
An unknown event type should not change the data instance.


test_mod_data_core_calendar_event_timestart_updated_open_event()   X-Ref
A DATA_EVENT_TYPE_OPEN event should update the timeavailablefrom property of the data activity.


test_mod_data_core_calendar_event_timestart_updated_close_event()   X-Ref
A DATA_EVENT_TYPE_CLOSE event should update the timeavailableto property of the data activity.


test_mod_data_core_calendar_get_valid_event_timestart_range_unknown_event()   X-Ref
An unknown event type should not have any limits.


test_mod_data_core_calendar_get_valid_event_timestart_range_open_event()   X-Ref
The open event should be limited by the data's timeclose property, if it's set.


test_mod_data_core_calendar_get_valid_event_timestart_range_close_event()   X-Ref
The close event should be limited by the data's timeavailablefrom property, if it's set.


test_creation_with_no_calendar_capabilities()   X-Ref
A user who does not have capabilities to add events to the calendar should be able to create an database.