Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

A class for recording the definition of Mink replacements.

Copyright: 2019 Andrew Nicols <andrew@nicols.co.uk>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 99 lines (3 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

behat_component_named_replacement:: (3 methods):
  __construct()
  get_from()
  get_to()


Class: behat_component_named_replacement  - X-Ref

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

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%)'

__construct(string $from, string $to)   X-Ref
Create the replacement.

param: string $from this is the old selector that should no longer be used.
param: string $to this is the new equivalent that should be used instead.

get_from(string $component)   X-Ref
Get the 'from' part of the replacement, formatted for the component.

param: string $component
return: string

get_to()   X-Ref
Get the 'to' part of the replacement.

return: string Target xpath