public function StorageTest::testFormCached in Drupal 10
Same name and namespace in other branches
- 8 core/modules/system/tests/src/Functional/Form/StorageTest.php \Drupal\Tests\system\Functional\Form\StorageTest::testFormCached()
- 9 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 76
Class
- StorageTest
- Tests a multistep form using form storage and makes sure validation and caching works right.
Namespace
Drupal\Tests\system\Functional\FormCode
public function testFormCached() {
$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');
}