function StorageTest::testFormCached in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Form/StorageTest.php \Drupal\system\Tests\Form\StorageTest::testFormCached()
Tests using the form after calling $form_state->setCached().
File
- core/modules/ system/ src/ Tests/ Form/ StorageTest.php, line 68 
- Contains \Drupal\system\Tests\Form\StorageTest.
Class
- StorageTest
- Tests a multistep form using form storage and makes sure validation and caching works right.
Namespace
Drupal\system\Tests\FormCode
function testFormCached() {
  $this
    ->drupalGet('form_test/form-storage', array(
    'query' => array(
      'cache' => 1,
    ),
  ));
  $this
    ->assertText('Form constructions: 1');
  $edit = array(
    'title' => 'new',
    'value' => 'value_is_set',
  );
  // Use form rebuilding triggered by a submit button.
  $this
    ->drupalPostForm(NULL, $edit, 'Continue submit');
  // The first one is for the building of the form.
  $this
    ->assertText('Form constructions: 2');
  // The second one is for the rebuilding of the form.
  $this
    ->assertText('Form constructions: 3');
  // Reset the form to the values of the storage, using a form rebuild
  // triggered by button of type button.
  $this
    ->drupalPostForm(NULL, array(
    'title' => 'changed',
  ), 'Reset');
  $this
    ->assertFieldByName('title', 'new', 'Values have been reset.');
  $this
    ->assertText('Form constructions: 4');
  $this
    ->drupalPostForm(NULL, $edit, 'Save');
  $this
    ->assertText('Form constructions: 4');
  $this
    ->assertText('Title: new', 'The form storage has stored the values.');
}