private function UrlTest::hasAttribute in Drupal 10
Same name and namespace in other branches
- 9 core/modules/system/tests/src/Kernel/Common/UrlTest.php \Drupal\Tests\system\Kernel\Common\UrlTest::hasAttribute()
Checks for class existence in link.
Parameters
$attribute: Attribute to be checked.
$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/ Kernel/ Common/ UrlTest.php - Tests that default and custom attributes are handled correctly on links.
File
- core/
modules/ system/ tests/ src/ Kernel/ Common/ UrlTest.php, line 178
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\Kernel\CommonCode
private function hasAttribute($attribute, $link, $class) {
return (bool) preg_match('|' . $attribute . '="([^\\"\\s]+\\s+)*' . $class . '|', $link);
}