You are here

public function HtmlTest::testHtmlClass in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Component/Utility/HtmlTest.php \Drupal\Tests\Component\Utility\HtmlTest::testHtmlClass()

Tests that Html::getClass() cleans the class name properly.

@coversDefaultClass ::getClass

File

core/tests/Drupal/Tests/Component/Utility/HtmlTest.php, line 92

Class

HtmlTest
Tests \Drupal\Component\Utility\Html.

Namespace

Drupal\Tests\Component\Utility

Code

public function testHtmlClass() {

  // Verify Drupal coding standards are enforced.
  $this
    ->assertSame('class-name--ü', Html::getClass('CLASS NAME_[Ü]'), 'Enforce Drupal coding standards.');

  // Test Html::getClass() handles Drupal\Component\Render\MarkupInterface
  // input.
  $markup = HtmlTestMarkup::create('CLASS_FROM_OBJECT');
  $this
    ->assertSame('class-from-object', Html::getClass($markup), 'Markup object is converted to CSS class.');
}