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.

Behat helpers for TinyMCE Plugins.

Copyright: 2022 Andrew Lyons <andrew@nicols.co.uk>
File Size: 216 lines (7 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 10 functions


Functions that are not part of a class:

execute_javascript_for_editor(string $editorid, string $code)   X-Ref
Execute some JavaScript for a particular Editor instance.

The editor instance is available on the 'instnace' variable.

param: string $editorid The ID of the editor
param: string $code The code to execute

evaluate_javascript_for_editor(string $editorid, string $code)   X-Ref
Resolve some JavaScript for a particular Editor instance.

The editor instance is available on the 'instnace' variable.
The code should return a value by passing it to the `resolve` function.

param: string $editorid The ID of the editor
param: string $code The code to evaluate
return: string|null|array

set_editor_value(string $editorid, string $value)   X-Ref
Set the value for the editor.

Note: This function is called by the behat_form_editor class.
It is called regardless of the current default editor as editor selection is a user preference.
Therefore it must fail gracefully and only set a value if the editor instance was found on the page.

param: string $editorid
param: string $value

store_current_value(string $editorid)   X-Ref
Store the current value of the editor, if it is a Tiny editor, to the textarea.

param: string $editorid The ID of the editor.

require_tiny_tags()   X-Ref
Ensure that the editor_tiny tag is in use.

This function should be used for any step defined in this file.


get_textarea_for_locator(string $locator)   X-Ref
Get the Mink NodeElement of the <textarea> for the specified locator.

Moodle mostly referes to the textarea, rather than the editor itself and interactions are translated to the
Editor using the TinyMCE API.

param: string $locator A Moodle field locator
return: NodeElement The element found by the find_field function

get_editor_container_for_locator(string $locator)   X-Ref
Get the Mink NodeElement of the container for the specified locator.

This is the top-most HTML element for the editor found by TinyMCE.getContainer().

param: string $locator A Moodle field locator
return: NodeElement The Mink NodeElement representing the container.

get_editor_iframe_name(string $locator)   X-Ref
Get the name of the iframe relating to the editor.

If no name is found, then add one.

If the editor it not found, then throw an exception.

param: string $locator The name of the editor
return: string The name of the iframe

get_editor_iframe_name_for_element(NodeElement $editor)   X-Ref
Get the name of the iframe relating to the editor.

If no name is found, then add one.

If the editor it not found, then throw an exception.
param: NodeElement $editor The editor element
return: string The name of the iframe

normalise_fixture_filepath(string $filepath)   X-Ref
Normalise the fixture file path relative to the dirroot.

param: string $filepath
return: string