You are here

function FormTest::testRange in Zircon Profile 8

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

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

File

core/modules/system/src/Tests/Form/FormTest.php, line 524
Contains \Drupal\system\Tests\Form\FormTest.

Class

FormTest
Tests various form element validation mechanisms.

Namespace

Drupal\system\Tests\Form

Code

function testRange() {
  $values = json_decode($this
    ->drupalPostForm('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
    ->drupalPostForm('form-test/range/invalid', array(), 'Submit');
  $this
    ->assertFieldByXPath('//input[@type="range" and contains(@class, "error")]', NULL, 'Range element has the error class.');
}