You are here

protected function TaxonomyAccessFixTestTrait::assertNoLinkByEndOfHref in Taxonomy access fix 8.3

Same name and namespace in other branches
  1. 8.2 tests/src/Traits/TaxonomyAccessFixTestTrait.php \Drupal\Tests\taxonomy_access_fix\Traits\TaxonomyAccessFixTestTrait::assertNoLinkByEndOfHref()

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.

Throws

\PHPUnit\Framework\ExpectationFailedException When the assertion failed.

3 calls to TaxonomyAccessFixTestTrait::assertNoLinkByEndOfHref()
TermAccessTest::testTermAccess in tests/src/Functional/TermAccessTest.php
Test access control functionality for taxonomy terms.
VocabularyAccessTest::testTaxonomyVocabularyCollection in tests/src/Functional/VocabularyAccessTest.php
Tests access to administrative Taxonomy Vocabulary collection.
VocabularyAccessTest::testTaxonomyVocabularyOverview in tests/src/Functional/VocabularyAccessTest.php
Tests access to Taxonomy Vocabulary overview page.

File

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

Class

TaxonomyAccessFixTestTrait
Provides common methods for functional tests of Taxonomy Access Fix module.

Namespace

Drupal\Tests\taxonomy_access_fix\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,
  ]);
  $this
    ->assertTrue(empty($links), $message);
}