You are here

protected function PatchInfoTestTrait::assertNoLinkByEndOfHref in PatchInfo 8.2

Passes if a a link whose href attribute ends with a string is not found.

@todo Remove once https://www.drupal.org/node/2031223 has been fixed.

An optional element index may be passed.

Parameters

string $href: What the href attribute of the link should end with.

string $message: (optional) A message to display with the assertion. Do not translate messages: use strtr() to embed variables in the message text, not t(). If left blank, a default message will be displayed.

Return value

bool TRUE if the assertion succeeded, FALSE otherwise.

File

tests/src/Traits/PatchInfoTestTrait.php, line 107

Class

PatchInfoTestTrait
Provides common methods for functional tests of PatchInfo module.

Namespace

Drupal\Tests\patchinfo\Traits

Code

protected function assertNoLinkByEndOfHref($href, $message = '') {

  // This is an XPath 1.0 implementation of the ends-with() function.
  $links = $this
    ->xpath('//a[:href = substring(@href, string-length(@href) - ' . (strlen($href) + 1) . ')]', [
    ':href' => $href,
  ]);
  $message = $message ? $message : new FormattableMarkup('No link with href %href found.', [
    '%href' => $href,
  ]);
  return $this
    ->assertTrue(empty($links), $message);
}