function LinkGeneratorTest::assertNoXPathResults

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php \Drupal\Tests\Core\Utility\LinkGeneratorTest::assertNoXPathResults()
  2. 10 core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php \Drupal\Tests\Core\Utility\LinkGeneratorTest::assertNoXPathResults()
  3. 11.x 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 662

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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.