diff --git a/core/modules/simpletest/src/AssertContentTrait.php b/core/modules/simpletest/src/AssertContentTrait.php index e19f319..c6f8695 100644 --- a/core/modules/simpletest/src/AssertContentTrait.php +++ b/core/modules/simpletest/src/AssertContentTrait.php @@ -918,6 +918,10 @@ protected function assertFieldsByValue($fields, $value = NULL, $message = '', $g $found = FALSE; if ($fields) { foreach ($fields as $field) { + if (!($field instanceof \SimpleXmlElement)) { + throw new \InvalidArgumentException('Wrong trait in WTB!?!'); + } + if (isset($field['value']) && $field['value'] == $value) { // Input element with correct value. $found = TRUE; diff --git a/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php index 4426d62..1f33959 100644 --- a/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php +++ b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php @@ -569,7 +569,7 @@ protected function assertNoFieldByXPath($xpath, $value = NULL, $message = '') { /** * Asserts that a field exists in the current page with a given Xpath result. * - * @param \Behat\Mink\Element\NodeElement[] $fields + * @param [] $fields * Xml elements. * @param string $value * (optional) Value of the field to assert. You may pass in NULL (default) to skip @@ -589,6 +589,10 @@ protected function assertFieldsByValue($fields, $value = NULL, $message = '') { $found = FALSE; if ($fields) { foreach ($fields as $field) { + if (!($field instanceof \Behat\Mink\Element\NodeElement)) { + throw new \InvalidArgumentException('Wrong trait in BTB!?!'); + } + if ($field->getAttribute('value') == $value) { // Input element with correct value. $found = TRUE;