You are here

protected function LinkGeneratorTest::assertNoXPathResults in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php \Drupal\Tests\Core\Utility\LinkGeneratorTest::assertNoXPathResults()

Checks that the given XPath query has no results in a given HTML snippet.

Parameters

string $query: The XPath query to execute.

string $html: The HTML snippet to check.

Return value

int The number of results that are found.

2 calls to LinkGeneratorTest::assertNoXPathResults()
LinkGeneratorTest::testGenerateActive in core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
Tests the active class on the link method.
LinkGeneratorTest::testGenerateXss in core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
Tests the link method with a script tab.

File

core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php, line 692

Class

LinkGeneratorTest
@coversDefaultClass \Drupal\Core\Utility\LinkGenerator @group Utility

Namespace

Drupal\Tests\Core\Utility

Code

protected function assertNoXPathResults($query, $html) {
  $document = new \DOMDocument();
  $document
    ->loadHTML($html);
  $xpath = new \DOMXPath($document);
  self::assertFalse((bool) $xpath
    ->query($query)->length);
}