You are here

private function UrlTest::hasAttribute in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Common/UrlTest.php \Drupal\system\Tests\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/src/Tests/Common/UrlTest.php
Tests that default and custom attributes are handled correctly on links.

File

core/modules/system/src/Tests/Common/UrlTest.php, line 212
Contains \Drupal\system\Tests\Common\UrlTest.

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\system\Tests\Common

Code

private function hasAttribute($attribute, $link, $class) {
  return preg_match('|' . $attribute . '="([^\\"\\s]+\\s+)*' . $class . '|', $link);
}