diff -u b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php --- b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php +++ b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php @@ -430,8 +430,7 @@ protected function assertNoFieldById($id, $value = '') { $field = $this->getSession()->getPage()->findById($id); - // Manual test instead of assertNull() to keep the thrown exception the - // same. + // Return early if the field could not be found as expected. if ($field === NULL) { return; } @@ -439,8 +438,6 @@ if (!isset($value)) { throw new ExpectationException(sprintf('Id "%s" appears on this page, but it should not.', $id), $this->getSession()->getDriver()); } - // Manual test instead of assertEquals() to keep the thrown exception the - // same. elseif ($value === $field->getValue()) { throw new ExpectationException(sprintf('Failed asserting that %s is not equal to %s', $field->getValue(), $value), $this->getSession()->getDriver()); }