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

A class for recording the definition of Mink replacements for use in Mink selectors. More...

Public Member Functions

 __construct (string $from, string $to)
 Create the replacement.
 
 get_from (string $component)
 Get the 'from' part of the replacement, formatted for the component.
 
 get_to ()
 Get the 'to' part of the replacement.
 

Protected Attributes

string $from
 
string $to
 

Detailed Description

A class for recording the definition of Mink replacements for use in Mink selectors.

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

These are comprised of a source string, and a replacement.

During use the source string is converted from the string to be in the format:

 %[component]/[string]%

For example:

 %mod_forum/title%

Mink replacements are used in xpath translation to translate regularly used items such as title. Here is an example from the upstream Mink project:

'tagTextMatch' => 'contains(normalize-space(string(.)), locator%)'

And can be used in an xpath:

 .//label[%tagTextMatch%]

This would be expanded to:

 .//label[contains(normalize-space(string(.)), %locator%)]

Replacements can also be used in other replacements, as long as that replacement is defined later.

 '%linkMatch%' => '(%idMatch% or %tagTextMatch% or %titleMatch% or %relMatch%)'
License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

behat_component_named_replacement::__construct ( string $from,
string $to )

Create the replacement.

Parameters
string$fromthis is the old selector that should no longer be used. For example 'group_message'.
string$tothis is the new equivalent that should be used instead. For example 'core_message > Message'.

Member Function Documentation

◆ get_from()

behat_component_named_replacement::get_from ( string $component)

Get the 'from' part of the replacement, formatted for the component.

Parameters
string$component
Return values
string

◆ get_to()

behat_component_named_replacement::get_to ( )

Get the 'to' part of the replacement.

Return values
stringTarget xpath

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