Merge branch 'MDL-33671-master-fix' of git://github.com/andrewnicols/moodle

This commit is contained in:
Sara Arjona
2020-03-05 09:05:52 +01:00
+21 -4
View File
@@ -223,10 +223,7 @@ class behat_field_manager {
// If the type is explictly set on the element pointed to by the label - use it.
$fieldtype = $fieldnode->getAttribute('data-fieldtype');
if ($fieldtype) {
if ($fieldtype == 'tags') {
return 'autocomplete';
}
return $fieldtype;
return self::normalise_fieldtype($fieldtype);
}
if (!empty($fieldnode->find('xpath', '/ancestor::*[@data-passwordunmaskid]'))) {
@@ -236,6 +233,12 @@ class behat_field_manager {
// Fetch the parentnode only once.
$parentnode = $fieldnode->getParent();
// Check the parent fieldtype before we check classes.
$fieldtype = $parentnode->getAttribute('data-fieldtype');
if ($fieldtype) {
return self::normalise_fieldtype($fieldtype);
}
// We look for a parent node with 'felement' class.
if ($class = $parentnode->getAttribute('class')) {
if (strstr($class, 'felement') != false) {
@@ -252,6 +255,20 @@ class behat_field_manager {
return self::get_field_node_type($parentnode, $session);
}
/**
* Normalise the field type.
*
* @param string $fieldtype
* @return string
*/
protected static function normalise_fieldtype(string $fieldtype): string {
if ($fieldtype === 'tags') {
return 'autocomplete';
}
return $fieldtype;
}
/**
* Gets an instance of the form field.
*