function StorageTest::testForm
Same name in other branches
- 9 core/modules/system/tests/src/Functional/Form/StorageTest.php \Drupal\Tests\system\Functional\Form\StorageTest::testForm()
- 8.9.x core/modules/system/tests/src/Functional/Form/StorageTest.php \Drupal\Tests\system\Functional\Form\StorageTest::testForm()
- 10 core/modules/system/tests/src/Functional/Form/StorageTest.php \Drupal\Tests\system\Functional\Form\StorageTest::testForm()
Tests using the form in a usual way.
File
-
core/
modules/ system/ tests/ src/ Functional/ Form/ StorageTest.php, line 44
Class
- StorageTest
- Tests a multistep form using form storage.
Namespace
Drupal\Tests\system\Functional\FormCode
public function testForm() : void {
$this->drupalGet('form_test/form-storage');
$assert_session = $this->assertSession();
$assert_session->pageTextContains('Form constructions: 1');
$edit = [
'title' => 'new',
'value' => 'value_is_set',
];
// Use form rebuilding triggered by a submit button.
$this->submitForm($edit, 'Continue submit');
$assert_session->pageTextContains('Form constructions: 2');
$assert_session->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');
$assert_session->fieldValueEquals('title', 'new');
// After rebuilding, the form has been cached.
$assert_session->pageTextContains('Form constructions: 4');
$this->submitForm($edit, 'Save');
$assert_session->pageTextContains('Form constructions: 4');
// Verify that the form storage has stored the values.
$assert_session->pageTextContains('Title: new');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.