function UrlTest::hasAttribute
Same name in other branches
- 9 core/modules/system/tests/src/Kernel/Common/UrlTest.php \Drupal\Tests\system\Kernel\Common\UrlTest::hasAttribute()
- 10 core/modules/system/tests/src/Kernel/Common/UrlTest.php \Drupal\Tests\system\Kernel\Common\UrlTest::hasAttribute()
- 11.x core/modules/system/tests/src/Kernel/Common/UrlTest.php \Drupal\Tests\system\Kernel\Common\UrlTest::hasAttribute()
Checks for class existence in link.
Parameters
$link: URL to search.
$class: Element class to search for.
Return value
bool TRUE if the class is found, FALSE otherwise.
1 call to UrlTest::hasAttribute()
- UrlTest::testLinkAttributes in core/
modules/ system/ tests/ src/ Functional/ Common/ UrlTest.php - Tests that default and custom attributes are handled correctly on links.
File
-
core/
modules/ system/ tests/ src/ Functional/ Common/ UrlTest.php, line 215
Class
- UrlTest
- Confirm that \Drupal\Core\Url, \Drupal\Component\Utility\UrlHelper::filterQueryParameters(), \Drupal\Component\Utility\UrlHelper::buildQuery(), and \Drupal\Core\Utility\LinkGeneratorInterface::generate() work correctly with various input.
Namespace
Drupal\Tests\system\Functional\CommonCode
private function hasAttribute($attribute, $link, $class) {
return (bool) preg_match('|' . $attribute . '="([^\\"\\s]+\\s+)*' . $class . '|', $link);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.