Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 402 and 403]

Helper to get behat contexts from other contexts.

Copyright: 2014 David MonllaĆ³
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 194 lines (6 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

behat_context_helper:: (8 methods):
  set_session()
  set_environment()
  get()
  get_component_context()
  get_prefixed_contexts()
  get_theme_override()
  has_context()
  escape()


Class: behat_context_helper  - X-Ref

Helper to get behat contexts.

set_session(Environment $environment)   X-Ref
Sets the browser session.

param: Environment $environment
return: void

set_environment(Environment $environment)   X-Ref
Sets behat environment.

param: Environment $environment
return: void

get($classname)   X-Ref
Gets the required context.

Getting a context you get access to all the steps
that uses direct API calls; steps returning step chains
can not be executed like this.

param: string $classname Context identifier (the class name).
return: behat_base

get_component_context(string $component)   X-Ref
Get the context for the specified component or subsystem.

param: string $component The component or subsystem to find the context for
return: behat_base|null

get_prefixed_contexts(string $prefix)   X-Ref
Find all Behat contexts which match the specified context class name prefix.

Moodle uses a consistent class naming scheme for all Behat contexts, whereby the context name is in the format:

behat_{component}

This method will return all contexts which match the specified prefix.

For example, to find all editors, you would pass in 'behat_editor', and this might return:
- behat_editor_atto
- behat_editor_textarea

param: string $prefix The prefix to search for
return: \Behat\Behat\Context\Context[]

get_theme_override(string $classname)   X-Ref
Check for any theme override of the specified class name.

param: string $classname
return: string|null

has_context(string $classname)   X-Ref
Return whether there is a context of the specified classname.

param: string $classname
return: bool

escape($label)   X-Ref
Translates string to XPath literal.

param: string $label label to escape
return: string escaped string.