Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | List of all members
behat_theme_classic_behat_mod_forum Class Reference
Inheritance diagram for behat_theme_classic_behat_mod_forum:
behat_mod_forum behat_base

Public Member Functions

 __call ($name, $arguments)
 Finds DOM nodes in the page using named selectors. More...
 
 escape ($string)
 Escapes the double quote character. More...
 
 evaluate_script (string $script)
 Evaluate the supplied script in the current session, returning the result. More...
 
 execute_script (string $script)
 Execute the supplied script in the current session. More...
 
 get_sesskey ()
 Get the session key for the current session via Javascript. More...
 
 has_tag (string $tag)
 Checks if the current scenario, or its feature, has a specified tag. 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.
 
 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. 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.
 
 i_unsubscribe_from_this_forum ()
 Unsubscribes from the forum.
 
 look_for_exceptions ()
 Internal step definition to find exceptions, debugging() messages and PHP debug messages. More...
 
 normalise_selector (string $selector, $locator, Element $container)
 Normalise the locator and selector. 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...
 
 wait_for_pending_js ()
 Waits for all the JS to be loaded. More...
 

Static Public Member Functions

static evaluate_script_in_session (Session $session, string $script)
 Evaluate the supplied script in the specified session, returning the result. More...
 
static execute_script_in_session (Session $session, string $script)
 Excecute the supplied script in the specified session. More...
 
static get_exact_named_selectors ()
 Return a list of the exact named selectors for the component. More...
 
static get_extended_timeout ()
 Gets the extended timeout. More...
 
static get_named_replacements ()
 Return a list of the Mink named replacements for the component. More...
 
static get_partial_named_selectors ()
 Return a list of the partial named selectors for the component. More...
 
static get_reduced_timeout ()
 Gets the reduced timeout. More...
 
static get_timeout ()
 Gets the default timeout. More...
 
static set_user ($user=null)
 Set current $USER, reset access cache. More...
 
static wait_for_pending_js_in_session (Session $session)
 Waits for all the JS to be loaded. 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...
 
 ensure_editors_are_loaded ()
 Ensures that all the page's editors are loaded. More...
 
 ensure_element_does_not_exist ($locator, $selectortype)
 Spins until the element does not exist. More...
 
 ensure_element_exists ($locator, $selectortype)
 Spins around an element until it exists. More...
 
 ensure_element_is_visible ($element, $selectortype)
 Ensures that the provided element is visible and we can interact with it. More...
 
 ensure_node_attribute_is_set ($node, $attribute, $attributevalue)
 Ensures that the provided node has a attribute value set. More...
 
 ensure_node_is_visible ($node)
 Ensures that the provided node is visible and we can interact with it. More...
 
 execute ($contextapi, $params=array())
 Helper function to execute api in a given context. More...
 
 fill_new_discussion_form (TableNode $table)
 Fill in the forum's post form and submit. More...
 
 find ($selector, $locator, $exception=false, $node=false, $timeout=false)
 Returns the first matching element. More...
 
 find_all ($selector, $locator, $exception=false, $container=false, $timeout=false)
 Returns all matching elements. 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_debug_text ($html)
 Converts HTML tags to line breaks to display the info in CLI. 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_node_in_container ($selectortype, $element, $containerselectortype, $containerelement)
 Gets the requested element inside the specified container. More...
 
 get_selected_node ($selectortype, $element)
 Gets a NodeElement based on the locator and selector type received as argument from steps definitions. More...
 
 get_session_user ()
 Get the actual user in the behat session (note $USER does not correspond to the behat session's user). More...
 
 get_text_selector_node ($selectortype, $element)
 Gets a NodeElement based on the locator and selector type received as argument from steps definitions. 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...
 
 is_in_app ()
 Checks if the current page is part of the mobile app. More...
 
 js_trigger_click ($node)
 Trigger click on node via javascript instead of actually clicking on it via pointer. More...
 
 locate_path ($path)
 Locates url, based on provided path. More...
 
 require_javascript ()
 Require that javascript be available in the current Session. More...
 
 resize_window ($windowsize, $viewport=false)
 Change browser window size. More...
 
 resolve_page_instance_url (string $type, string $identifier)
 Convert page names to URLs for steps like 'When I am on the "[identifier]" "[page type]" page'. More...
 
 resolve_page_url (string $page)
 Convert page names to URLs for steps like 'When I am on the "[page name]" page'. More...
 
 running_javascript ()
 Whether Javascript is available in the current Session. More...
 
 spin ($lambda, $args=false, $timeout=false, $exception=false, $microsleep=false)
 Executes the passed closure until returns true or time outs. More...
 
 transform_selector ($selectortype, $element)
 Transforms from step definition's argument style to Mink format. More...
 
 transform_text_selector ($selectortype, $element)
 Transforms from step definition's argument style to Mink format. More...
 

Static Protected Member Functions

static get_real_timeout (int $timeout)
 Gets the required timeout in seconds. More...
 
static require_javascript_in_session (Session $session)
 Require that javascript be available for the specified Session. More...
 
static running_javascript_in_session (Session $session)
 Whether Javascript is available in the specified Session. More...
 

Member Function Documentation

◆ __call()

behat_base::__call (   $name,
  $arguments 
)
inherited

Finds DOM nodes in the page using named selectors.

The point of using this method instead of Mink ones is the spin method of behat_base::find() that looks for the element until it is available or it timeouts, this avoids the false failures received when selenium tries to execute commands on elements that are not ready to be used.

All steps that requires elements to be available before interact with them should use one of the find* methods.

The methods calls requires a {'find_' . $elementtype}($locator) format, like find_link($locator), find_select($locator), find_button($locator)...

@externalurl http://mink.behat.org/#named-selectors

Exceptions
coding_exception
Parameters
string$nameThe name of the called method
mixed$arguments
Return values
NodeElement

◆ add_new_discussion()

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

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 
)
protectedinherited

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 
)
protectedinherited

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

◆ ensure_editors_are_loaded()

behat_base::ensure_editors_are_loaded ( )
protectedinherited

Ensures that all the page's editors are loaded.

Deprecated:
since Moodle 2.7 MDL-44084 - please do not use this function any more.
Exceptions
ElementNotFoundException
ExpectationException
Return values
void

◆ ensure_element_does_not_exist()

behat_base::ensure_element_does_not_exist (   $locator,
  $selectortype 
)
protectedinherited

Spins until the element does not exist.

Exceptions
ExpectationException
Parameters
string$locator
string$selectortype
Return values
void

◆ ensure_element_exists()

behat_base::ensure_element_exists (   $locator,
  $selectortype 
)
protectedinherited

Spins around an element until it exists.

Exceptions
ExpectationException
Parameters
string$locator
string$selectortype
Return values
void

◆ ensure_element_is_visible()

behat_base::ensure_element_is_visible (   $element,
  $selectortype 
)
protectedinherited

Ensures that the provided element is visible and we can interact with it.

Returns the node in case other actions are interested in using it.

Exceptions
ExpectationException
Parameters
string$element
string$selectortype
Return values
NodeElementThrows an exception if it times out without being visible

◆ ensure_node_attribute_is_set()

behat_base::ensure_node_attribute_is_set (   $node,
  $attribute,
  $attributevalue 
)
protectedinherited

Ensures that the provided node has a attribute value set.

This step can be used to check if specific JS has finished modifying the node.

Exceptions
ExpectationException
Parameters
NodeElement$node
string$attributeattribute name
string$attributevalueattribute value to check.
Return values
voidThrows an exception if it times out without the element being visible

◆ ensure_node_is_visible()

behat_base::ensure_node_is_visible (   $node)
protectedinherited

Ensures that the provided node is visible and we can interact with it.

Exceptions
ExpectationException
Parameters
NodeElement$node
Return values
voidThrows an exception if it times out without the element being visible

◆ escape()

behat_base::escape (   $string)
inherited

Escapes the double quote character.

Double quote is the argument delimiter, it can be escaped with a backslash, but we auto-remove this backslashes before the step execution, this method is useful when using arguments as arguments for other steps.

Parameters
string$string
Return values
string

◆ evaluate_script()

behat_base::evaluate_script ( string  $script)
inherited

Evaluate the supplied script in the current session, returning the result.

Parameters
string$script
Return values
mixed

◆ evaluate_script_in_session()

static behat_base::evaluate_script_in_session ( Session  $session,
string  $script 
)
staticinherited

Evaluate the supplied script in the specified session, returning the result.

Parameters
Session$session
string$script
Return values
mixed

◆ execute()

behat_base::execute (   $contextapi,
  $params = array() 
)
protectedinherited

Helper function to execute api in a given context.

Parameters
string$contextapicontext in which api is defined.
array$paramslist of params to pass.
Exceptions
Exception

◆ execute_script()

behat_base::execute_script ( string  $script)
inherited

Execute the supplied script in the current session.

No result will be returned.

Parameters
string$script

◆ execute_script_in_session()

static behat_base::execute_script_in_session ( Session  $session,
string  $script 
)
staticinherited

Excecute the supplied script in the specified session.

No result will be returned.

Parameters
Session$session
string$script

◆ fill_new_discussion_form()

behat_mod_forum::fill_new_discussion_form ( TableNode  $table)
protectedinherited

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

◆ find()

behat_base::find (   $selector,
  $locator,
  $exception = false,
  $node = false,
  $timeout = false 
)
protectedinherited

Returns the first matching element.

@externalurl http://mink.behat.org/#traverse-the-page-selectors

Parameters
string$selectorThe selector type (css, xpath, named...)
mixed$locatorIt depends on the $selector, can be the xpath, a name, a css locator...
Exception$exceptionOtherwise we throw exception with generic info
NodeElement$nodeSpins around certain DOM node instead of the whole page
int$timeoutForces a specific time out (in seconds).
Return values
NodeElement

◆ find_all()

behat_base::find_all (   $selector,
  $locator,
  $exception = false,
  $container = false,
  $timeout = false 
)
protectedinherited

Returns all matching elements.

Adapter to Behat\Mink\Element\Element::findAll() using the spin() method.

@externalurl http://mink.behat.org/#traverse-the-page-selectors

Parameters
string$selectorThe selector type (css, xpath, named...)
mixed$locatorIt depends on the $selector, can be the xpath, a name, a css locator...
Exception$exceptionOtherwise we throw expcetion with generic info
NodeElement$containerRestrict the search to just children of the specified container
int$timeoutForces a specific time out (in seconds). If 0 is provided the default timeout will be applied.
Return values
arrayNodeElements list

◆ get_base_discussion()

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

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)
protectedinherited

Fetch course ID using course name.

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

◆ get_debug_text()

behat_base::get_debug_text (   $html)
protectedinherited

Converts HTML tags to line breaks to display the info in CLI.

Parameters
string$html
Return values
string

◆ get_exact_named_selectors()

static behat_base::get_exact_named_selectors ( )
staticinherited

Return a list of the exact named selectors for the component.

Named selectors are what make Behat steps like Then I should see "Useful text" in the "General" "fieldset" work. Here, "fieldset" is the named selector, and "General" is the locator.

If you override this method in your plugin (e.g. mod_mymod), to define new selectors specific to your plugin. For example, if you returned new behat_component_named_selector('Thingy', [".//some/xpath//img[contains(@alt, %locator%)]/.."]) then Then I should see "Useful text" in the "Whatever" "mod_mymod > Thingy" would work.

This method should return a list of behat_component_named_selector and the docs on that class explain how it works.

Return values
behat_component_named_selector[]

◆ get_extended_timeout()

static behat_base::get_extended_timeout ( )
staticinherited

Gets the extended timeout.

A longer timeout for cases where the normal timeout is not enough.

Return values
intTimeout in seconds

◆ get_forum_id()

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

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 
)
protectedinherited

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_named_replacements()

static behat_base::get_named_replacements ( )
staticinherited

Return a list of the Mink named replacements for the component.

Named replacements allow you to define parts of an xpath that can be reused multiple times, or in multiple xpaths.

This method should return a list of behat_component_named_replacement and the docs on that class explain how it works.

Return values
behat_component_named_replacement[]

Reimplemented in behat_message.

◆ get_node_in_container()

behat_base::get_node_in_container (   $selectortype,
  $element,
  $containerselectortype,
  $containerelement 
)
protectedinherited

Gets the requested element inside the specified container.

Exceptions
ElementNotFoundExceptionThrown by behat_base::find
Parameters
mixed$selectortypeThe element selector type.
mixed$elementThe element locator.
mixed$containerselectortypeThe container selector type.
mixed$containerelementThe container locator.
Return values
NodeElement

◆ get_partial_named_selectors()

static behat_base::get_partial_named_selectors ( )
staticinherited

Return a list of the partial named selectors for the component.

Like the exact named selectors above, but the locator only needs to match part of the text. For example, the standard "button" is a partial selector, so: When I click "Save" "button" will activate "Save changes".

Return values
behat_component_named_selector[]

Reimplemented in behat_message.

◆ get_real_timeout()

static behat_base::get_real_timeout ( int  $timeout)
staticprotectedinherited

Gets the required timeout in seconds.

Parameters
int$timeoutOne of the TIMEOUT constants
Return values
intActual timeout (in seconds)

◆ get_reduced_timeout()

static behat_base::get_reduced_timeout ( )
staticinherited

Gets the reduced timeout.

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

Return values
intTimeout in seconds

◆ get_selected_node()

behat_base::get_selected_node (   $selectortype,
  $element 
)
protectedinherited

Gets a NodeElement based on the locator and selector type received as argument from steps definitions.

Use behat_base::get_text_selector_node() for text-based selectors.

Exceptions
ElementNotFoundExceptionThrown by behat_base::find
Parameters
string$selectortype
string$element
Return values
NodeElement

◆ get_session_user()

behat_base::get_session_user ( )
protectedinherited

Get the actual user in the behat session (note $USER does not correspond to the behat session's user).

Return values
mixed
Exceptions
coding_exception

◆ get_sesskey()

behat_base::get_sesskey ( )
inherited

Get the session key for the current session via Javascript.

Return values
string

◆ get_text_selector_node()

behat_base::get_text_selector_node (   $selectortype,
  $element 
)
protectedinherited

Gets a NodeElement based on the locator and selector type received as argument from steps definitions.

Exceptions
ElementNotFoundExceptionThrown by behat_base::find
Parameters
string$selectortype
string$element
Return values
NodeElement

◆ get_timeout()

static behat_base::get_timeout ( )
staticinherited

Gets the default timeout.

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

Return values
intTimeout in seconds

◆ get_user_id()

behat_mod_forum::get_user_id (   $username)
protectedinherited

Fetch user ID from its username.

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

◆ goto_main_post_reply()

behat_mod_forum::goto_main_post_reply (   $postsubject)
protectedinherited

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

◆ has_tag()

behat_base::has_tag ( string  $tag)
inherited

Checks if the current scenario, or its feature, has a specified tag.

Parameters
string$tagTag to check
Return values
boolTrue if the tag exists in scenario or feature

◆ i_add_a_forum_discussion_to_forum_inline_with()

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

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 
)
inherited

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 
)
inherited

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 
)
inherited

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_click_on_action_menu()

behat_mod_forum::i_click_on_action_menu (   $discussion)
inherited

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 
)
inherited

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 
)
inherited

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 
)
inherited

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

◆ is_in_app()

behat_base::is_in_app ( )
protectedinherited

Checks if the current page is part of the mobile app.

Return values
boolTrue if it's in the app

◆ js_trigger_click()

behat_base::js_trigger_click (   $node)
protectedinherited

Trigger click on node via javascript instead of actually clicking on it via pointer.

This function resolves the issue of nested elements with click listeners or links - in these cases clicking via the pointer may accidentally cause a click on the wrong element. Example of issue: clicking to expand navigation nodes when the config value linkadmincategories is enabled.

Parameters
NodeElement$node

◆ locate_path()

behat_base::locate_path (   $path)
protectedinherited

Locates url, based on provided path.

Override to provide custom routing mechanism.

See also
Behat\MinkExtension\Context\MinkContext
Parameters
string$path
Return values
string

◆ look_for_exceptions()

behat_base::look_for_exceptions ( )
inherited

Internal step definition to find exceptions, debugging() messages and PHP debug messages.

Part of behat_hooks class as is part of the testing framework, is auto-executed after each step so no features will splicitly use it.

Exceptions
ExceptionUnknown type, depending on what we caught in the hook or basic Exception.
See also
Moodle\BehatExtension\Tester\MoodleStepTester

◆ normalise_selector()

behat_base::normalise_selector ( string  $selector,
  $locator,
Element  $container 
)
inherited

Normalise the locator and selector.

Parameters
string$selectorThe type of thing to search
mixed$locatorThe locator value. Can be an array, but is more likely a string.
Element$containerAn optional container to search within
Return values
arrayThe selector, locator, and container to search within

◆ require_javascript()

behat_base::require_javascript ( )
protectedinherited

Require that javascript be available in the current Session.

Exceptions
DriverException

◆ require_javascript_in_session()

static behat_base::require_javascript_in_session ( Session  $session)
staticprotectedinherited

Require that javascript be available for the specified Session.

Parameters
Session$session
Exceptions
DriverException

◆ resize_window()

behat_base::resize_window (   $windowsize,
  $viewport = false 
)
protectedinherited

Change browser window size.

  • small: 640x480
  • medium: 1024x768
  • large: 2560x1600
Parameters
string$windowsizesize of window.
bool$viewportIf true, changes viewport rather than window size
Exceptions
ExpectationException

◆ resolve_page_instance_url()

behat_base::resolve_page_instance_url ( string  $type,
string  $identifier 
)
protectedinherited

Convert page names to URLs for steps like 'When I am on the "[identifier]" "[page type]" page'.

A typical example might be: When I am on the "Test quiz" "mod_quiz > Responses report" page which would cause this method in behat_mod_quiz to be called with arguments 'Responses report', 'Test quiz'.

You should override this as appropriate for your plugin. The method behat_navigation::resolve_core_page_instance_url() is a good example.

Your overridden method should document the recognised page types with a table like this:

Recognised page names are: | Type | identifier meaning | Description |

Parameters
string$typeidentifies which type of page this is, e.g. 'Attempt review'.
string$identifieridentifies the particular page, e.g. 'Test quiz > student > Attempt 1'.
Return values
moodle_urlthe corresponding URL.
Exceptions
Exceptionwith a meaningful error message if the specified page cannot be found.

Reimplemented in behat_mod_quiz, and behat_core_form.

◆ resolve_page_url()

behat_base::resolve_page_url ( string  $page)
protectedinherited

Convert page names to URLs for steps like 'When I am on the "[page name]" page'.

You should override this as appropriate for your plugin. The method behat_navigation::resolve_core_page_url() is a good example.

Your overridden method should document the recognised page types with a table like this:

Recognised page names are: | Page | Description |

Parameters
string$pagename of the page, with the component name removed e.g. 'Admin notification'.
Return values
moodle_urlthe corresponding URL.
Exceptions
Exceptionwith a meaningful error message if the specified page cannot be found.

Reimplemented in behat_mod_quiz, and behat_core_form.

◆ running_javascript()

behat_base::running_javascript ( )
protectedinherited

Whether Javascript is available in the current Session.

Return values
boolean

◆ running_javascript_in_session()

static behat_base::running_javascript_in_session ( Session  $session)
staticprotectedinherited

Whether Javascript is available in the specified Session.

Parameters
Session$session
Return values
boolean

◆ set_user()

static behat_base::set_user (   $user = null)
staticinherited

Set current $USER, reset access cache.

In some cases, behat will execute the code as admin but in many cases we need to set an specific user as some API's might rely on the logged user to take some action.

Parameters
null | int | stdClass$useruser record, null or 0 means non-logged-in, positive integer means userid

◆ spin()

behat_base::spin (   $lambda,
  $args = false,
  $timeout = false,
  $exception = false,
  $microsleep = false 
)
protectedinherited

Executes the passed closure until returns true or time outs.

In most cases the document.readyState === 'complete' will be enough, but sometimes JS requires more time to be completely loaded or an element to be visible or whatever is required to perform some action on an element; this method receives a closure which should contain the required statements to ensure the step definition actions and assertions have all their needs satisfied and executes it until they are satisfied or it timeouts. Redirects the return of the closure to the caller.

The closures requirements to work well with this spin method are:

  • Must return false, null or '' if something goes wrong
  • Must return something != false if finishes as expected, this will be the (mixed) value returned by spin()

The arguments of the closure are mixed, use $args depending on your needs.

You can provide an exception to give more accurate feedback to tests writers, otherwise the closure exception will be used, but you must provide an exception if the closure does not throw an exception.

Exceptions
ExceptionIf it timeouts without receiving something != false from the closure
Parameters
Function | array | string$lambdaThe function to execute or an array passed to call_user_func (maps to a class method)
mixed$argsArguments to pass to the closure
int$timeoutTimeout in seconds
Exception$exceptionThe exception to throw in case it time outs.
bool$microsleepIf set to true it'll sleep micro seconds rather than seconds.
Return values
mixedThe value returned by the closure

◆ the_following_forum_discussions_exist()

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

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 
)
inherited

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.

◆ transform_selector()

behat_base::transform_selector (   $selectortype,
  $element 
)
protectedinherited

Transforms from step definition's argument style to Mink format.

Mink has 3 different selectors css, xpath and named, where named selectors includes link, button, field... to simplify and group multiple steps in one we use the same interface, considering all link, buttons... at the same level as css selectors and xpath; this method makes the conversion from the arguments received by the steps to the selectors and locators required to interact with Mink.

Exceptions
ExpectationException
Parameters
string$selectortypeIt can be css, xpath or any of the named selectors.
string$elementThe locator (or string) we are looking for.
Return values
arrayContains the selector and the locator expected by Mink.

◆ transform_text_selector()

behat_base::transform_text_selector (   $selectortype,
  $element 
)
protectedinherited

Transforms from step definition's argument style to Mink format.

Delegates all the process to behat_base::transform_selector() checking the provided $selectortype.

Exceptions
ExpectationException
Parameters
string$selectortypeIt can be css, xpath or any of the named selectors.
string$elementThe locator (or string) we are looking for.
Return values
arrayContains the selector and the locator expected by Mink.

◆ wait_for_pending_js()

behat_base::wait_for_pending_js ( )
inherited

Waits for all the JS to be loaded.

Return values
boolWhether any JS is still pending completion.

◆ wait_for_pending_js_in_session()

static behat_base::wait_for_pending_js_in_session ( Session  $session)
staticinherited

Waits for all the JS to be loaded.

Parameters
Session$sessionThe Mink Session where JS can be run
Return values
boolWhether any JS is still pending completion.

Member Data Documentation

◆ EXTENDED_TIMEOUT

const behat_base::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 4.1
See also
behat_base::get_extended_timeout()

◆ PAGE_READY_JS

const behat_base::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_base::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 4.1
See also
behat_base::get_reduced_timeout()

◆ TIMEOUT

const behat_base::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 4.1
See also
behat_base::get_timeout()

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