Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 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.

Class: behat_mod_forum  - X-Ref

Forum-related steps definitions.

i_add_a_new_topic_to_forum_with($forumname, TableNode $table)   X-Ref
Adds a topic to the forum specified by it's name. Useful for the Announcements and blog-style forums.

param: string $forumname
param: TableNode $table

i_add_a_new_question_to_forum_with($forumname, TableNode $table)   X-Ref
Adds a Q&A discussion to the Q&A-type forum specified by it's name with the provided table data.

param: string $forumname
param: TableNode $table

i_add_a_forum_discussion_to_forum_with($forumname, TableNode $table)   X-Ref
Adds a discussion to the forum specified by it's name with the provided table data (usually Subject and Message). The step begins from the forum's course page.

param: string $forumname
param: TableNode $table

i_add_a_forum_discussion_to_forum_inline_with($forumname, TableNode $table)   X-Ref
Adds a discussion to the forum specified by it's name with the provided table data (usually Subject and Message).
The step begins from the forum's course page.

param: string $forumname
param: TableNode $table

i_reply_post_from_forum_with($postsubject, $forumname, TableNode $table)   X-Ref
Adds a reply to the specified post of the specified forum. The step begins from the forum's page or from the forum's course page.

param: string $postname The subject of the post
param: string $forumname The forum name
param: TableNode $table

i_reply_post_from_forum_using_an_inpage_reply_with($postsubject, $forumname, TableNode $table)   X-Ref
Inpage Reply - adds a reply to the specified post of the specified forum. The step begins from the forum's page or from the forum's course page.

param: string $postsubject The subject of the post
param: string $forumname The forum name
param: TableNode $table

i_navigate_to_post_in_forum($postsubject, $forumname)   X-Ref
Navigates to a particular discussion page

param: string $postsubject The subject of the post
param: string $forumname The forum name

i_click_on_action_menu($discussion)   X-Ref
Opens up the action menu for the discussion

param: string $discussion The subject of the discussion

the_following_forum_discussions_exist(string $coursename, TableNode $discussionsdata)   X-Ref
Creates new discussions within forums of a given course.

param: string $coursename The full name of the course where the forums exist.
param: TableNode $discussionsdata The discussion posts to be created.

the_following_forum_replies_exist(string $coursename, TableNode $repliesdata)   X-Ref
Creates replies to discussions within forums of a given course.

param: string $coursename The full name of the course where the forums exist.
param: TableNode $repliesdata The reply posts to be created.

i_can_subscribe_to_this_forum()   X-Ref
Checks if the user can subscribe to the forum.


i_can_unsubscribe_from_this_forum()   X-Ref
Checks if the user can unsubscribe from the forum.


i_subscribe_to_this_forum()   X-Ref
Subscribes to the forum.


i_unsubscribe_from_this_forum()   X-Ref
Unsubscribes from the forum.


get_user_id($username)   X-Ref
Fetch user ID from its username.

param: string $username The username.
return: int The user ID.

get_course_id(string $coursename)   X-Ref
Fetch course ID using course name.

param: string $coursename The name of the course.
return: int The course ID.

get_forum_id(int $courseid, string $forumname)   X-Ref
Fetch forum ID using forum name.

param: int $courseid The course ID the forum exists within.
param: string $forumname The name of the forum.
return: int The forum ID.

get_group_id(int $courseid, string $groupname)   X-Ref
Fetch Group ID using group name.

param: int $courseid The course ID the forum exists within.
param: string $groupname The short name of the group.
return: int The group ID.

get_base_discussion(int $forumid, string $name)   X-Ref
Fetch discussion ID and first post ID by discussion name.

param: int $forumid The forum ID where the discussion resides.
param: string $name The name of the discussion.
return: array The discussion ID and first post ID.

create_post_attachments(int $postid, int $userid, array $attachmentnames, stdClass $cm, string $filearea)   X-Ref
Create one or more attached or inline attachments to a forum post.

param: int $postid The ID of the forum post.
param: int $userid The user ID creating the attachment.
param: array $attachmentnames Names of all attachments to be created.
param: stdClass $cm The context module of the forum.
param: string $filearea The file area being written to, eg 'attachment' or 'post' (inline).

add_new_discussion($forumname, TableNode $table, $buttonstr)   X-Ref
Returns the steps list to add a new discussion to a forum.

Abstracts add a new topic and add a new discussion, as depending
on the forum type the button string changes.

param: string $forumname
param: TableNode $table
param: string $buttonstr

add_new_discussion_inline($forumname, TableNode $table, $buttonstr)   X-Ref
Returns the steps list to add a new discussion to a forum inline.

Abstracts add a new topic and add a new discussion, as depending
on the forum type the button string changes.

param: string $forumname
param: TableNode $table
param: string $buttonstr

fill_new_discussion_form(TableNode $table)   X-Ref
Fill in the forum's post form and submit. It assumes you've already navigated and enabled the form for view.

param: TableNode $table

goto_main_post_reply($postsubject)   X-Ref
Go to the default reply to post page.
This is used instead of navigating through 4-5 different steps and to solve issues where JS would be required to click
on the advanced button

param: $postsubject