Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

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

The module forums tests

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

Defines 1 class

mod_forum_lib_testcase:: (72 methods):
  setUp()
  tearDown()
  test_forum_trigger_content_uploaded_event()
  test_forum_get_courses_user_posted_in()
  test_forum_tp_can_track_forums()
  test_forum_tp_is_tracked()
  test_forum_tp_get_course_unread_posts()
  test_forum_tp_get_course_unread_posts_with_private_replies()
  test_forum_tp_count_forum_unread_posts_with_private_replies()
  test_forum_tp_count_forum_unread_posts_with_private_replies_and_separate_groups()
  test_forum_tp_get_untracked_forums()
  test_forum_auto_subscribe_on_create()
  test_forum_forced_subscribe_on_create()
  test_forum_optional_subscribe_on_create()
  test_forum_disallow_subscribe_on_create()
  test_forum_get_context()
  test_forum_get_neighbours()
  test_forum_get_neighbours_blog()
  test_forum_get_neighbours_with_groups()
  test_forum_get_neighbours_with_groups_blog()
  test_count_discussion_replies_basic()
  test_count_discussion_replies_limited()
  test_count_discussion_replies_paginated()
  test_count_discussion_replies_paginated_sorted()
  test_count_discussion_replies_limited_sorted()
  test_count_discussion_replies_paginated_sorted_small()
  test_count_discussion_replies_paginated_sorted_small_reverse()
  test_count_discussion_replies_limited_sorted_small_reverse()
  test_forum_count_discussion_replies_private()
  test_discussion_pinned_sort()
  test_forum_view()
  test_forum_discussion_view()
  create_multiple_discussions_with_replies()
  create_single_discussion_with_replies()
  create_single_discussion_pinned_with_replies()
  test_mod_forum_rating_can_see_item_ratings()
  test_forum_get_discussions_with_groups()
  test_forum_user_can_post_discussion()
  test_forum_user_can_post_discussion_after_cutoff()
  test_forum_user_has_posted_discussion_no_groups()
  test_forum_user_has_posted_discussion_multiple_forums()
  test_forum_user_has_posted_discussion_multiple_groups()
  test_mod_forum_myprofile_navigation()
  test_mod_forum_myprofile_navigation_as_guest()
  test_mod_forum_myprofile_navigation_different_user()
  test_pinned_discussion_with_group()
  test_pinned_with_timed_discussions()
  test_pinned_timed_discussions_with_timed_discussions()
  test_forum_is_author_hidden()
  test_forum_discussion_is_locked()
  forum_discussion_is_locked_provider()
  test_forum_is_cutoff_date_reached()
  forum_is_cutoff_date_reached_provider()
  test_forum_is_due_date_reached()
  forum_is_due_date_reached_provider()
  test_forum_update_post_keeps_discussions_usermodified()
  test_forum_core_calendar_provide_event_action()
  test_forum_core_calendar_provide_event_action_in_hidden_section()
  test_forum_core_calendar_provide_event_action_for_user()
  test_forum_core_calendar_provide_event_action_as_non_user()
  test_forum_core_calendar_provide_event_action_already_completed()
  test_forum_core_calendar_provide_event_action_already_completed_for_user()
  test_mod_forum_get_tagged_posts()
  create_action_event()
  test_mod_forum_completion_get_active_rule_descriptions()
  test_forum_post_is_visible_privately()
  test_mod_forum_core_calendar_get_valid_event_timestart_range_unknown_event()
  test_mod_forum_core_calendar_get_valid_event_timestart_range_due_no_limit()
  test_mod_forum_core_calendar_get_valid_event_timestart_range_due_with_limits()
  test_mod_forum_core_calendar_event_timestart_updated_unknown_event()
  test_mod_forum_core_calendar_event_timestart_updated_due_event()
  test_forum_get_layout_modes()


Class: mod_forum_lib_testcase  - X-Ref

setUp()   X-Ref
No description

tearDown()   X-Ref
No description

test_forum_trigger_content_uploaded_event()   X-Ref
No description

test_forum_get_courses_user_posted_in()   X-Ref
No description

test_forum_tp_can_track_forums()   X-Ref
Test the logic in the forum_tp_can_track_forums() function.


test_forum_tp_is_tracked()   X-Ref
Test the logic in the test_forum_tp_is_tracked() function.


test_forum_tp_get_course_unread_posts()   X-Ref
Test the logic in the forum_tp_get_course_unread_posts() function.


test_forum_tp_get_course_unread_posts_with_private_replies()   X-Ref
Test the logic in the forum_tp_get_course_unread_posts() function when private replies are present.


test_forum_tp_count_forum_unread_posts_with_private_replies()   X-Ref
Test the logic in the forum_tp_count_forum_unread_posts() function when private replies are present but without
separate group mode. This should yield the same results returned by forum_tp_get_course_unread_posts().


test_forum_tp_count_forum_unread_posts_with_private_replies_and_separate_groups()   X-Ref
Test the logic in the forum_tp_count_forum_unread_posts() function when private replies are present and group modes are set.


test_forum_tp_get_untracked_forums()   X-Ref
Test the logic in the test_forum_tp_get_untracked_forums() function.


test_forum_auto_subscribe_on_create()   X-Ref
Test subscription using automatic subscription on create.


test_forum_forced_subscribe_on_create()   X-Ref
Test subscription using forced subscription on create.


test_forum_optional_subscribe_on_create()   X-Ref
Test subscription using optional subscription on create.


test_forum_disallow_subscribe_on_create()   X-Ref
Test subscription using disallow subscription on create.


test_forum_get_context()   X-Ref
Test that context fetching returns the appropriate context.


test_forum_get_neighbours()   X-Ref
Test getting the neighbour threads of a discussion.


test_forum_get_neighbours_blog()   X-Ref
Test getting the neighbour threads of a blog-like forum.


test_forum_get_neighbours_with_groups()   X-Ref
Test getting the neighbour threads of a discussion.


test_forum_get_neighbours_with_groups_blog()   X-Ref
Test getting the neighbour threads of a blog-like forum with groups involved.


test_count_discussion_replies_basic()   X-Ref
No description

test_count_discussion_replies_limited()   X-Ref
No description

test_count_discussion_replies_paginated()   X-Ref
No description

test_count_discussion_replies_paginated_sorted()   X-Ref
No description

test_count_discussion_replies_limited_sorted()   X-Ref
No description

test_count_discussion_replies_paginated_sorted_small()   X-Ref
No description

test_count_discussion_replies_paginated_sorted_small_reverse()   X-Ref
No description

test_count_discussion_replies_limited_sorted_small_reverse()   X-Ref
No description

test_forum_count_discussion_replies_private()   X-Ref
Test the reply count when used with private replies.


test_discussion_pinned_sort()   X-Ref
No description

test_forum_view()   X-Ref
No description

test_forum_discussion_view()   X-Ref
Test forum_discussion_view.


create_multiple_discussions_with_replies($discussioncount, $replycount)   X-Ref
Create a new course, forum, and user with a number of discussions and replies.

param: int $discussioncount The number of discussions to create
param: int $replycount The number of replies to create in each discussion
return: array Containing the created forum object, and the ids of the created discussions.

create_single_discussion_with_replies($forum, $user, $replycount)   X-Ref
Create a discussion with a number of replies.

param: object $forum The forum which has been created
param: object $user The user making the discussion and replies
param: int $replycount The number of replies
return: object $discussion

create_single_discussion_pinned_with_replies($forum, $user, $replycount)   X-Ref
Create a discussion with a number of replies.

param: object $forum The forum which has been created
param: object $user The user making the discussion and replies
param: int $replycount The number of replies
return: object $discussion

test_mod_forum_rating_can_see_item_ratings()   X-Ref
Tests for mod_forum_rating_can_see_item_ratings().


test_forum_get_discussions_with_groups()   X-Ref
Test forum_get_discussions


test_forum_user_can_post_discussion()   X-Ref
Test forum_user_can_post_discussion


test_forum_user_can_post_discussion_after_cutoff()   X-Ref
Test forum_user_can_post_discussion_after_cutoff


test_forum_user_has_posted_discussion_no_groups()   X-Ref
Test forum_user_has_posted_discussion with no groups.


test_forum_user_has_posted_discussion_multiple_forums()   X-Ref
Test forum_user_has_posted_discussion with multiple forums


test_forum_user_has_posted_discussion_multiple_groups()   X-Ref
Test forum_user_has_posted_discussion with multiple groups.


test_mod_forum_myprofile_navigation()   X-Ref
Tests the mod_forum_myprofile_navigation() function.


test_mod_forum_myprofile_navigation_as_guest()   X-Ref
Tests the mod_forum_myprofile_navigation() function as a guest.


test_mod_forum_myprofile_navigation_different_user()   X-Ref
Tests the mod_forum_myprofile_navigation() function as a user viewing another user's profile.


test_pinned_discussion_with_group()   X-Ref
Test test_pinned_discussion_with_group.


test_pinned_with_timed_discussions()   X-Ref
Test test_pinned_with_timed_discussions.


test_pinned_timed_discussions_with_timed_discussions()   X-Ref
Test test_pinned_timed_discussions_with_timed_discussions.


test_forum_is_author_hidden()   X-Ref
Test for forum_is_author_hidden.


test_forum_discussion_is_locked($forum, $discussion, $expect)   X-Ref
Test the forum_discussion_is_locked function.

param: stdClass    $forum
param: stdClass    $discussion
param: bool        $expect

forum_discussion_is_locked_provider()   X-Ref
Dataprovider for forum_discussion_is_locked tests.

return: array

test_forum_is_cutoff_date_reached($forum, $expect)   X-Ref
Test the forum_is_cutoff_date_reached function.

param: array   $forum
param: bool    $expect

forum_is_cutoff_date_reached_provider()   X-Ref
Dataprovider for forum_is_cutoff_date_reached tests.

return: array

test_forum_is_due_date_reached($forum, $expect)   X-Ref
Test the forum_is_due_date_reached function.

param: stdClass    $forum
param: bool        $expect

forum_is_due_date_reached_provider()   X-Ref
Dataprovider for forum_is_due_date_reached tests.

return: array

test_forum_update_post_keeps_discussions_usermodified()   X-Ref
Test that {@link forum_update_post()} keeps correct forum_discussions usermodified.


test_forum_core_calendar_provide_event_action()   X-Ref
No description

test_forum_core_calendar_provide_event_action_in_hidden_section()   X-Ref
No description

test_forum_core_calendar_provide_event_action_for_user()   X-Ref
No description

test_forum_core_calendar_provide_event_action_as_non_user()   X-Ref
No description

test_forum_core_calendar_provide_event_action_already_completed()   X-Ref
No description

test_forum_core_calendar_provide_event_action_already_completed_for_user()   X-Ref
No description

test_mod_forum_get_tagged_posts()   X-Ref
No description

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

param: int $courseid The course id.
param: int $instanceid The instance id.
param: string $eventtype The event type.
return: bool|calendar_event

test_mod_forum_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_forum_post_is_visible_privately()   X-Ref
Test the forum_post_is_visible_privately function used in private replies.


test_mod_forum_core_calendar_get_valid_event_timestart_range_unknown_event()   X-Ref
An unkown event type should not have any limits


test_mod_forum_core_calendar_get_valid_event_timestart_range_due_no_limit()   X-Ref
Forums configured without a cutoff date should not have any limits applied.


test_mod_forum_core_calendar_get_valid_event_timestart_range_due_with_limits()   X-Ref
Forums should be top bound by the cutoff date.


test_mod_forum_core_calendar_event_timestart_updated_unknown_event()   X-Ref
An unknown event type should not change the forum instance.


test_mod_forum_core_calendar_event_timestart_updated_due_event()   X-Ref
Due date events should update the forum due date.


test_forum_get_layout_modes()   X-Ref
Test forum_get_layout_modes function.