You are here

protected function LinkGeneratorTest::assertNoXPathResults in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php \Drupal\Tests\Core\Utility\LinkGeneratorTest::assertNoXPathResults()
  2. 9 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.

@internal

Parameters

string $query: The XPath query to execute.

string $html: The HTML snippet to check.

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 693

Class

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

Namespace

Drupal\Tests\Core\Utility

Code

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