MDL-43738 behat: More info about how to get/set fields
This commit is contained in:
@@ -29,6 +29,8 @@ $string['errorcomposer'] = 'Composer dependencies are not installed.';
|
||||
$string['errordataroot'] = '$CFG->behat_dataroot is not set or is invalid.';
|
||||
$string['errorsetconfig'] = '$CFG->behat_dataroot, $CFG->behat_prefix and $CFG->behat_wwwroot need to be set in config.php.';
|
||||
$string['erroruniqueconfig'] = '$CFG->behat_dataroot, $CFG->behat_prefix and $CFG->behat_wwwroot values need to be different than $CFG->dataroot, $CFG->prefix, $CFG->wwwroot, $CFG->phpunit_dataroot and $CFG->phpunit_prefix values.';
|
||||
$string['fieldvalueargument'] = 'Field value arguments';
|
||||
$string['fieldvalueargument_help'] = 'This argument should be completed by a field value, there are many field types, simple ones like checkboxes, selects or textareas or complex ones like date selectors. You can check <a href="http://docs.moodle.org/dev/Acceptance_testing#Providing_values_to_steps" target="_blank">Field values</a> to see the expected field value depending on the field type you provide.';
|
||||
$string['giveninfo'] = 'Given. Processes to set up the environment';
|
||||
$string['infoheading'] = 'Info';
|
||||
$string['installinfo'] = 'Read {$a} for installation and tests execution info';
|
||||
|
||||
@@ -84,6 +84,33 @@ class tool_behat_renderer extends plugin_renderer_base {
|
||||
$stepsdefinitions
|
||||
);
|
||||
|
||||
$stepsdefinitions = preg_replace_callback('/(FIELD_VALUE_STRING)/',
|
||||
function ($matches) {
|
||||
global $CFG;
|
||||
|
||||
// Creating a link to a popup with the help.
|
||||
$url = new moodle_url(
|
||||
'/help.php',
|
||||
array(
|
||||
'component' => 'tool_behat',
|
||||
'identifier' => 'fieldvalueargument',
|
||||
'lang' => current_language()
|
||||
)
|
||||
);
|
||||
|
||||
// Note: this title is displayed only if JS is disabled,
|
||||
// otherwise the link will have the new ajax tooltip.
|
||||
$title = get_string('fieldvalueargument', 'tool_behat');
|
||||
$title = get_string('helpprefix2', '', trim($title, ". \t"));
|
||||
|
||||
$attributes = array('href' => $url, 'title' => $title,
|
||||
'aria-haspopup' => 'true', 'target' => '_blank');
|
||||
|
||||
$output = html_writer::tag('a', 'FIELD_VALUE_STRING', $attributes);
|
||||
return html_writer::tag('span', $output, array('class' => 'helptooltip'));
|
||||
},
|
||||
$stepsdefinitions
|
||||
);
|
||||
}
|
||||
|
||||
// Steps definitions.
|
||||
|
||||
@@ -148,7 +148,7 @@ class behat_forms extends behat_base {
|
||||
/**
|
||||
* Sets the specified value to the field.
|
||||
*
|
||||
* @Given /^I set the field "(?P<field_string>(?:[^"]|\\")*)" to "(?P<value_string>(?:[^"]|\\")*)"$/
|
||||
* @Given /^I set the field "(?P<field_string>(?:[^"]|\\")*)" to "(?P<field_value_string>(?:[^"]|\\")*)"$/
|
||||
* @throws ElementNotFoundException Thrown by behat_base::find
|
||||
* @param string $field
|
||||
* @param string $value
|
||||
@@ -161,7 +161,7 @@ class behat_forms extends behat_base {
|
||||
/**
|
||||
* Checks, the field matches the value. More info in http://docs.moodle.org/dev/Acceptance_testing#Providing_values_to_steps.
|
||||
*
|
||||
* @Then /^the field "(?P<field_string>(?:[^"]|\\")*)" matches value "(?P<value_string>(?:[^"]|\\")*)"$/
|
||||
* @Then /^the field "(?P<field_string>(?:[^"]|\\")*)" matches value "(?P<field_value_string>(?:[^"]|\\")*)"$/
|
||||
* @throws ElementNotFoundException Thrown by behat_base::find
|
||||
* @param string $field
|
||||
* @param string $value
|
||||
@@ -187,7 +187,7 @@ class behat_forms extends behat_base {
|
||||
/**
|
||||
* Checks, the field does not match the value. More info in http://docs.moodle.org/dev/Acceptance_testing#Providing_values_to_steps.
|
||||
*
|
||||
* @Then /^the field "(?P<field_string>(?:[^"]|\\")*)" does not match value "(?P<value_string>(?:[^"]|\\")*)"$/
|
||||
* @Then /^the field "(?P<field_string>(?:[^"]|\\")*)" does not match value "(?P<field_value_string>(?:[^"]|\\")*)"$/
|
||||
* @throws ExpectationException
|
||||
* @throws ElementNotFoundException Thrown by behat_base::find
|
||||
* @param string $field
|
||||
@@ -232,7 +232,7 @@ class behat_forms extends behat_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that fields values do not match the provided values. Provide a table with field/value data.
|
||||
* Checks that the provided field/value pairs don't match. More info in http://docs.moodle.org/dev/Acceptance_testing#Providing_values_to_steps.
|
||||
*
|
||||
* @Then /^the following fields do not match these values:$/
|
||||
* @throws ExpectationException
|
||||
|
||||
Reference in New Issue
Block a user