Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
behat_mod_forum Class Reference
Inheritance diagram for behat_mod_forum:
behat_base behat_session_interface behat_theme_classic_behat_mod_forum

Public Member Functions

 getSession ($name=null)
 Returns the Mink session. More...
 
 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). More...
 
 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). More...
 
 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. More...
 
 i_add_a_new_topic_to_forum_with ($forumname, TableNode $table)
 Adds a topic to the forum specified by it's name. More...
 
 i_can_subscribe_to_this_forum ()
 Checks if the user can subscribe to the forum. More...
 
 i_can_unsubscribe_from_this_forum ()
 Checks if the user can unsubscribe from the forum. More...
 
 i_click_on_action_menu ($discussion)
 Opens up the action menu for the discussion. More...
 
 i_navigate_to_post_in_forum ($postsubject, $forumname)
 Navigates to a particular discussion page. More...
 
 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. More...
 
 i_reply_post_from_forum_with ($postsubject, $forumname, TableNode $table)
 Adds a reply to the specified post of the specified forum. More...
 
 i_subscribe_to_this_forum ()
 Subscribes to the forum. More...
 
 i_unsubscribe_from_this_forum ()
 Unsubscribes from the forum. More...
 
 the_following_forum_discussions_exist (string $coursename, TableNode $discussionsdata)
 Creates new discussions within forums of a given course. More...
 
 the_following_forum_replies_exist (string $coursename, TableNode $repliesdata)
 Creates replies to discussions within forums of a given course. More...
 

Public Attributes

const EXTENDED_TIMEOUT = 10
 And extended timeout for specific cases. More...
 
const PAGE_READY_JS
 The JS code to check that the page is ready. More...
 
const REDUCED_TIMEOUT = 2
 Small timeout. More...
 
const TIMEOUT = 6
 The timeout for each Behat step (load page, wait for an element to load...). More...
 

Protected Member Functions

 add_new_discussion ($forumname, TableNode $table, $buttonstr)
 Returns the steps list to add a new discussion to a forum. More...
 
 add_new_discussion_inline ($forumname, TableNode $table, $buttonstr)
 Returns the steps list to add a new discussion to a forum inline. More...
 
 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. More...
 
 fill_new_discussion_form (TableNode $table)
 Fill in the forum's post form and submit. More...
 
 get_base_discussion (int $forumid, string $name)
 Fetch discussion ID and first post ID by discussion name. More...
 
 get_course_id (string $coursename)
 Fetch course ID using course name. More...
 
 get_forum_id (int $courseid, string $forumname)
 Fetch forum ID using forum name. More...
 
 get_group_id (int $courseid, string $groupname)
 Fetch Group ID using group name. More...
 
 get_user_id ($username)
 Fetch user ID from its username. More...
 
 goto_main_post_reply ($postsubject)
 Go to the default reply to post page. More...
 

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$/

Reimplemented in behat_theme_classic_behat_mod_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$/

Reimplemented in behat_theme_classic_behat_mod_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$/

Reimplemented in behat_theme_classic_behat_mod_forum.

◆ i_unsubscribe_from_this_forum()

behat_mod_forum::i_unsubscribe_from_this_forum ( )

Unsubscribes from the forum.

@Given /^I unsubscribe from this forum$/

Reimplemented in behat_theme_classic_behat_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

◆ EXTENDED_TIMEOUT

const behat_session_interface::EXTENDED_TIMEOUT = 10
inherited

And extended timeout for specific cases.

Deprecated:
since Moodle 3.7 MDL-64979 - please use get_extended_timeout() instead
Todo:
MDL-64982 This will be deleted in Moodle 3.11
See also
behat_base::get_extended_timeout()

◆ 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.

◆ REDUCED_TIMEOUT

const behat_session_interface::REDUCED_TIMEOUT = 2
inherited

Small timeout.

A reduced timeout for cases where self::TIMEOUT is too much and a simple $this->getSession()->getPage()->find() could not be enough.

Deprecated:
since Moodle 3.7 MDL-64979 - please use get_reduced_timeout() instead
Todo:
MDL-64982 This will be deleted in Moodle 3.11
See also
behat_base::get_reduced_timeout()

◆ TIMEOUT

const behat_session_interface::TIMEOUT = 6
inherited

The timeout for each Behat step (load page, wait for an element to load...).

Deprecated:
since Moodle 3.7 MDL-64979 - please use get_timeout() instead
Todo:
MDL-64982 This will be deleted in Moodle 3.11
See also
behat_base::get_timeout()

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