function ElementTest::testButtonClasses
Same name in other branches
- 9 core/modules/system/tests/src/Functional/Form/ElementTest.php \Drupal\Tests\system\Functional\Form\ElementTest::testButtonClasses()
- 8.9.x core/modules/system/tests/src/Functional/Form/ElementTest.php \Drupal\Tests\system\Functional\Form\ElementTest::testButtonClasses()
- 11.x core/modules/system/tests/src/Functional/Form/ElementTest.php \Drupal\Tests\system\Functional\Form\ElementTest::testButtonClasses()
Tests button classes.
1 call to ElementTest::testButtonClasses()
- ElementTest::testFormElements in core/
modules/ system/ tests/ src/ Functional/ Form/ ElementTest.php - Test form elements.
File
-
core/
modules/ system/ tests/ src/ Functional/ Form/ ElementTest.php, line 140
Class
- ElementTest
- Tests building and processing of core form elements.
Namespace
Drupal\Tests\system\Functional\FormCode
protected function testButtonClasses() : void {
$this->drupalGet('form-test/button-class');
// Just contains(@class, "button") won't do because then
// "button--foo" would contain "button". Instead, check
// " button ". Make sure it matches in the beginning and the end too
// by adding a space before and after.
$this->assertSession()
->elementsCount('xpath', '//*[contains(concat(" ", @class, " "), " button ")]', 2);
$this->assertSession()
->elementsCount('xpath', '//*[contains(concat(" ", @class, " "), " button--foo ")]', 1);
$this->assertSession()
->elementsCount('xpath', '//*[contains(concat(" ", @class, " "), " button--danger ")]', 1);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.