private function UrlTest::hasAttribute in Drupal 9
Checks for class existence in link.
Parameters
$attribute:
$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 177
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);
}