Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
behat_mod_forum Class Reference

Forum-related steps definitions. More...

Inheritance diagram for behat_mod_forum:
behat_base behat_session_interface

Public Member Functions

 getSession ($name=null)
 Returns the Mink session.
 
 i_add_a_forum_discussion_to_forum_inline_with ($forumname, TableNode $table)
 Adds a discussion to the forum specified by it's name with the provided table data (usually Subject and Message).
 
 i_add_a_forum_discussion_to_forum_with ($forumname, TableNode $table)
 Adds a discussion to the forum specified by it's name with the provided table data (usually Subject and Message).
 
 i_add_a_new_question_to_forum_with ($forumname, TableNode $table)
 Adds a Q&A discussion to the Q&A-type forum specified by it's name with the provided table data.
 
 i_add_a_new_topic_to_forum_with ($forumname, TableNode $table)
 Adds a topic to the forum specified by it's name.
 
 i_can_subscribe_to_this_forum ()
 Checks if the user can subscribe to the forum.
 
 i_can_unsubscribe_from_this_forum ()
 Checks if the user can unsubscribe from the forum.
 
 i_click_on_action_menu ($discussion)
 Opens up the action menu for the discussion.
 
 i_navigate_to_post_in_forum ($postsubject, $forumname)
 Navigates to a particular discussion page.
 
 i_reply_post_from_forum_using_an_inpage_reply_with ($postsubject, $forumname, TableNode $table)
 Inpage Reply - adds a reply to the specified post of the specified forum.
 
 i_reply_post_from_forum_with ($postsubject, $forumname, TableNode $table)
 Adds a reply to the specified post of the specified forum.
 
 i_subscribe_to_this_forum ()
 Subscribes to the forum.
 
 i_unsubscribe_from_this_forum ()
 Unsubscribes from the forum.
 
 reset_forum_caches ()
 Reset forum caches between tests.
 
 the_following_forum_discussions_exist (string $coursename, TableNode $discussionsdata)
 Creates new discussions within forums of a given course.
 
 the_following_forum_replies_exist (string $coursename, TableNode $repliesdata)
 Creates replies to discussions within forums of a given course.
 

Public Attributes

const PAGE_READY_JS
 The JS code to check that the page is ready.
 

Protected Member Functions

 add_new_discussion ($forumname, TableNode $table, $buttonstr)
 Returns the steps list to add a new discussion to a forum.
 
 add_new_discussion_inline ($forumname, TableNode $table, $buttonstr)
 Returns the steps list to add a new discussion to a forum inline.
 
 create_post_attachments (int $postid, int $userid, array $attachmentnames, stdClass $cm, string $filearea)
 Create one or more attached or inline attachments to a forum post.
 
 fill_new_discussion_form (TableNode $table)
 Fill in the forum's post form and submit.
 
 get_base_discussion (int $forumid, string $name)
 Fetch discussion ID and first post ID by discussion name.
 
 get_course_id (string $coursename)
 Fetch course ID using course name.
 
 get_forum_id (int $courseid, string $forumname)
 Fetch forum ID using forum name.
 
 get_group_id (int $courseid, string $groupname)
 Fetch Group ID using group name.
 
 get_user_id ($username)
 Fetch user ID from its username.
 
 goto_main_post_reply ($postsubject)
 Go to the default reply to post page.
 

Detailed Description

Forum-related steps definitions.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ add_new_discussion()

behat_mod_forum::add_new_discussion ( $forumname,
TableNode $table,
$buttonstr )
protected

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.

Parameters
string$forumname
TableNode$table
string$buttonstr

◆ add_new_discussion_inline()

behat_mod_forum::add_new_discussion_inline ( $forumname,
TableNode $table,
$buttonstr )
protected

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.

Parameters
string$forumname
TableNode$table
string$buttonstr

◆ create_post_attachments()

behat_mod_forum::create_post_attachments ( int $postid,
int $userid,
array $attachmentnames,
stdClass $cm,
string $filearea )
protected

Create one or more attached or inline attachments to a forum post.

Parameters
int$postidThe ID of the forum post.
int$useridThe user ID creating the attachment.
array$attachmentnamesNames of all attachments to be created.
stdClass$cmThe context module of the forum.
string$fileareaThe file area being written to, eg 'attachment' or 'post' (inline).

◆ fill_new_discussion_form()

behat_mod_forum::fill_new_discussion_form ( TableNode $table)
protected

Fill in the forum's post form and submit.

It assumes you've already navigated and enabled the form for view.

Parameters
TableNode$table
Exceptions
coding_exception

◆ get_base_discussion()

behat_mod_forum::get_base_discussion ( int $forumid,
string $name )
protected

Fetch discussion ID and first post ID by discussion name.

Parameters
int$forumidThe forum ID where the discussion resides.
string$nameThe name of the discussion.
Return values
arrayThe discussion ID and first post ID.
Exceptions
dml_exceptionIf the discussion name is not unique within the forum (or doesn't exist).

◆ get_course_id()

behat_mod_forum::get_course_id ( string $coursename)
protected

Fetch course ID using course name.

Parameters
string$coursenameThe name of the course.
Return values
intThe course ID.
Exceptions
Exception

◆ get_forum_id()

behat_mod_forum::get_forum_id ( int $courseid,
string $forumname )
protected

Fetch forum ID using forum name.

Parameters
int$courseidThe course ID the forum exists within.
string$forumnameThe name of the forum.
Return values
intThe forum ID.
Exceptions
Exception

◆ get_group_id()

behat_mod_forum::get_group_id ( int $courseid,
string $groupname )
protected

Fetch Group ID using group name.

Parameters
int$courseidThe course ID the forum exists within.
string$groupnameThe short name of the group.
Return values
intThe group ID.
Exceptions
Exception

◆ get_user_id()

behat_mod_forum::get_user_id ( $username)
protected

Fetch user ID from its username.

Parameters
string$usernameThe username.
Return values
intThe user ID.
Exceptions
Exception

◆ getSession()

behat_session_interface::getSession ( $name = null)
inherited

Returns the Mink session.

Parameters
string | null$namename of the session OR active session will be used
Return values
Behat\Mink\Session

Implemented in behat_form_field.

◆ goto_main_post_reply()

behat_mod_forum::goto_main_post_reply ( $postsubject)
protected

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

Parameters
$postsubject
Exceptions
coding_exception
dml_exception
moodle_exception

◆ i_add_a_forum_discussion_to_forum_inline_with()

behat_mod_forum::i_add_a_forum_discussion_to_forum_inline_with ( $forumname,
TableNode $table )

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.

@Given /^I add a new discussion to "(?P<forum_name_string>(?:[^"]|::")*)" forum inline with:$/

Parameters
string$forumname
TableNode$table

◆ i_add_a_forum_discussion_to_forum_with()

behat_mod_forum::i_add_a_forum_discussion_to_forum_with ( $forumname,
TableNode $table )

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.

@Given /^I add a new discussion to "(?P<forum_name_string>(?:[^"]|::")*)" forum with:$/

Parameters
string$forumname
TableNode$table

◆ i_add_a_new_question_to_forum_with()

behat_mod_forum::i_add_a_new_question_to_forum_with ( $forumname,
TableNode $table )

Adds a Q&A discussion to the Q&A-type forum specified by it's name with the provided table data.

@Given /^I add a new question to "(?P<forum_name_string>(?:[^"]|::")*)" forum with:$/

Parameters
string$forumname
TableNode$table

◆ i_add_a_new_topic_to_forum_with()

behat_mod_forum::i_add_a_new_topic_to_forum_with ( $forumname,
TableNode $table )

Adds a topic to the forum specified by it's name.

Useful for the Announcements and blog-style forums.

@Given /^I add a new topic to "(?P<forum_name_string>(?:[^"]|::")*)" forum with:$/

Parameters
string$forumname
TableNode$table

◆ i_can_subscribe_to_this_forum()

behat_mod_forum::i_can_subscribe_to_this_forum ( )

Checks if the user can subscribe to the forum.

@Given /^I can subscribe to this forum$/

◆ i_can_unsubscribe_from_this_forum()

behat_mod_forum::i_can_unsubscribe_from_this_forum ( )

Checks if the user can unsubscribe from the forum.

@Given /^I can unsubscribe from this forum$/

◆ i_click_on_action_menu()

behat_mod_forum::i_click_on_action_menu ( $discussion)

Opens up the action menu for the discussion.

@Given /^I click on "(?P<post_subject_string>(?:[^"]|::")*)" action menu$/

Parameters
string$discussionThe subject of the discussion

◆ i_navigate_to_post_in_forum()

behat_mod_forum::i_navigate_to_post_in_forum ( $postsubject,
$forumname )

Navigates to a particular discussion page.

@Given /^I navigate to post "(?P<post_subject_string>(?:[^"]|::")*)" in "(?P<forum_name_string>(?:[^"]|")*)" forum$/

Parameters
string$postsubjectThe subject of the post
string$forumnameThe forum name

◆ i_reply_post_from_forum_using_an_inpage_reply_with()

behat_mod_forum::i_reply_post_from_forum_using_an_inpage_reply_with ( $postsubject,
$forumname,
TableNode $table )

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.

@Given /^I reply "(?P<post_subject_string>(?:[^"]|::")*)" post from "(?P<forum_name_string>(?:[^"]|")*)" forum using an inpage reply with:$/

Parameters
string$postsubjectThe subject of the post
string$forumnameThe forum name
TableNode$table

◆ i_reply_post_from_forum_with()

behat_mod_forum::i_reply_post_from_forum_with ( $postsubject,
$forumname,
TableNode $table )

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.

@Given /^I reply "(?P<post_subject_string>(?:[^"]|::")*)" post from "(?P<forum_name_string>(?:[^"]|")*)" forum with:$/

Parameters
string$postnameThe subject of the post
string$forumnameThe forum name
TableNode$table

◆ i_subscribe_to_this_forum()

behat_mod_forum::i_subscribe_to_this_forum ( )

Subscribes to the forum.

@Given /^I subscribe to this forum$/

◆ i_unsubscribe_from_this_forum()

behat_mod_forum::i_unsubscribe_from_this_forum ( )

Unsubscribes from the forum.

@Given /^I unsubscribe from this forum$/

◆ reset_forum_caches()

behat_mod_forum::reset_forum_caches ( )

Reset forum caches between tests.

@BeforeScenario @mod_forum

◆ the_following_forum_discussions_exist()

behat_mod_forum::the_following_forum_discussions_exist ( string $coursename,
TableNode $discussionsdata )

Creates new discussions within forums of a given course.

@Given the following forum discussions exist in course :coursename:

Parameters
string$coursenameThe full name of the course where the forums exist.
TableNode$discussionsdataThe discussion posts to be created.

◆ the_following_forum_replies_exist()

behat_mod_forum::the_following_forum_replies_exist ( string $coursename,
TableNode $repliesdata )

Creates replies to discussions within forums of a given course.

@Given the following forum replies exist in course :coursename:

Parameters
string$coursenameThe full name of the course where the forums exist.
TableNode$repliesdataThe reply posts to be created.

Member Data Documentation

◆ PAGE_READY_JS

const behat_session_interface::PAGE_READY_JS
inherited
Initial value:
= "document.readyState === 'complete' && " .
"(typeof M !== 'object' || typeof M.util !== 'object' || " .
"typeof M.util.pending_js === 'undefined' || M.util.pending_js.length === 0)"

The JS code to check that the page is ready.

The document must be complete and either M.util.pending_js must be empty, or it must not be defined at all.


The documentation for this class was generated from the following file: