Issue 3167034: do not use try/catch on test

merge-requests/25/head
Edys Meza 2020-09-28 11:38:52 -06:00
parent 2175e1f04d
commit f59f12f871
1 changed files with 2 additions and 29 deletions

View File

@ -42,35 +42,8 @@ class ImageLoadingAttributeTest extends BrowserTestBase {
$assert->elementAttributeContains('css', '#override-loading-attribute img', 'loading', 'eager');
// Without image dimensions loading attribute is not generated.
$this->assertFalse($this->elementAttributeExists($assert, 'css', '#without-dimensions img', 'loading'));
}
/**
* Checks that an attribuet exists in an element.
*
* Exends Drupal\Tests\WebAssert::elementAttributeExists() method to returns a
* boolean type instead throwing an execption when attribuet is not found.
*
* @param \Drupal\Tests\WebAssert $assert
* @param string $selectorType
* @param string|array $selector
* @param string $attribute
*
* @see Drupal\Tests\WebAssert::elementAttributeExists()
*
* @return bool
* Returns TRUE if $attribute exists, FALSE otherwise.
*/
protected function elementAttributeExists(WebAssert $assert, $selectorType, $selector, $attribute) {
$attribute_exists = TRUE;
try {
$assert->elementAttributeExists($selectorType, $selector, $attribute);
}
catch (ElementHtmlException $th) {
$attribute_exists = FALSE;
}
return $attribute_exists;
$element = $assert->elementExists('css', '#without-dimensions img');
$this->assertFalse($element->hasAttribute('loading'));
}
}