function AttributeTest::assertClass

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Template/AttributeTest.php \Drupal\Tests\Core\Template\AttributeTest::assertClass()
  2. 10 core/tests/Drupal/Tests/Core/Template/AttributeTest.php \Drupal\Tests\Core\Template\AttributeTest::assertClass()
  3. 11.x core/tests/Drupal/Tests/Core/Template/AttributeTest.php \Drupal\Tests\Core\Template\AttributeTest::assertClass()

Checks that the given CSS class is present in the given HTML snippet.

@internal

Parameters

string $class: The CSS class to check.

string $html: The HTML snippet to check.

1 call to AttributeTest::assertClass()
AttributeTest::testPrint in core/tests/Drupal/Tests/Core/Template/AttributeTest.php
Tests printing of an attribute.

File

core/tests/Drupal/Tests/Core/Template/AttributeTest.php, line 388

Class

AttributeTest
@coversDefaultClass \Drupal\Core\Template\Attribute @group Template

Namespace

Drupal\Tests\Core\Template

Code

protected function assertClass(string $class, string $html) : void {
    $xpath = "//*[@class='{$class}']";
    self::assertTrue((bool) $this->getXPathResultCount($xpath, $html));
}

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