You are here

function ElementTest::testButtonClasses in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Form/ElementTest.php \Drupal\system\Tests\Form\ElementTest::testButtonClasses()

Tests button classes.

File

core/modules/system/src/Tests/Form/ElementTest.php, line 114
Contains \Drupal\system\Tests\Form\ElementTest.

Class

ElementTest
Tests building and processing of core form elements.

Namespace

Drupal\system\Tests\Form

Code

function testButtonClasses() {
  $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
    ->assertEqual(2, count($this
    ->xpath('//*[contains(concat(" ", @class, " "), " button ")]')));
  $this
    ->assertEqual(1, count($this
    ->xpath('//*[contains(concat(" ", @class, " "), " button--foo ")]')));
  $this
    ->assertEqual(1, count($this
    ->xpath('//*[contains(concat(" ", @class, " "), " button--danger ")]')));
}