public function AttributeTest::testHasClass in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Template/AttributeTest.php \Drupal\Tests\Core\Template\AttributeTest::testHasClass()
- 10 core/tests/Drupal/Tests/Core/Template/AttributeTest.php \Drupal\Tests\Core\Template\AttributeTest::testHasClass()
Tests checking for class names with the Attribute method. @covers ::hasClass
File
- core/
tests/ Drupal/ Tests/ Core/ Template/ AttributeTest.php, line 230
Class
- AttributeTest
- @coversDefaultClass \Drupal\Core\Template\Attribute @group Template
Namespace
Drupal\Tests\Core\TemplateCode
public function testHasClass() {
// Test an attribute without any classes.
$attribute = new Attribute();
$this
->assertFalse($attribute
->hasClass('a-class-nowhere-to-be-found'));
// Add a class to check for.
$attribute
->addClass('we-totally-have-this-class');
// Check that this class exists.
$this
->assertTrue($attribute
->hasClass('we-totally-have-this-class'));
}