mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-33671 behat: Check current fieldtype and parent
This commit is contained in:
parent
ff1a10333d
commit
0e09bc932d
@ -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.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user