function StorageTest::testFormCached
Same name in other branches
- 9 core/modules/system/tests/src/Functional/Form/StorageTest.php \Drupal\Tests\system\Functional\Form\StorageTest::testFormCached()
- 8.9.x core/modules/system/tests/src/Functional/Form/StorageTest.php \Drupal\Tests\system\Functional\Form\StorageTest::testFormCached()
- 10 core/modules/system/tests/src/Functional/Form/StorageTest.php \Drupal\Tests\system\Functional\Form\StorageTest::testFormCached()
Tests using the form after calling $form_state->setCached().
File
-
core/
modules/ system/ tests/ src/ Functional/ Form/ StorageTest.php, line 73
Class
- StorageTest
- Tests a multistep form using form storage.
Namespace
Drupal\Tests\system\Functional\FormCode
public function testFormCached() : void {
$this->drupalGet('form_test/form-storage', [
'query' => [
'cache' => 1,
],
]);
$this->assertSession()
->pageTextContains('Form constructions: 1');
$edit = [
'title' => 'new',
'value' => 'value_is_set',
];
// Use form rebuilding triggered by a submit button.
$this->submitForm($edit, 'Continue submit');
// The first one is for the building of the form.
$this->assertSession()
->pageTextContains('Form constructions: 2');
// The second one is for the rebuilding of the form.
$this->assertSession()
->pageTextContains('Form constructions: 3');
// Reset the form to the values of the storage, using a form rebuild
// triggered by button of type button.
$this->submitForm([
'title' => 'changed',
], 'Reset');
$this->assertSession()
->fieldValueEquals('title', 'new');
$this->assertSession()
->pageTextContains('Form constructions: 4');
$this->submitForm($edit, 'Save');
$this->assertSession()
->pageTextContains('Form constructions: 4');
// Verify that the form storage has stored the values.
$this->assertSession()
->pageTextContains('Title: new');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.