function FormTest::testRange

Tests default value handling of #type 'range' elements.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php, line 432
Definition of Drupal\system\Tests\Form\FormTest.

Class

FormTest

Namespace

Drupal\system\Tests\Form

Code

function testRange() {
  $values = json_decode($this
    ->drupalPost('form-test/range', array(), 'Submit'));
  $this
    ->assertEqual($values->with_default_value, 18);
  $this
    ->assertEqual($values->float, 10.5);
  $this
    ->assertEqual($values->integer, 6);
  $this
    ->assertEqual($values->offset, 6.9);
  $this
    ->drupalPost('form-test/range/invalid', array(), 'Submit');
  $this
    ->assertFieldByXPath('//input[@type="range" and contains(@class, "error")]', NULL, 'Range element has the error class.');
}