function FormStoragePageCacheTest::getFormBuildId
Same name and namespace in other branches
- 10 core/modules/system/tests/src/Functional/Form/FormStoragePageCacheTest.php \Drupal\Tests\system\Functional\Form\FormStoragePageCacheTest::getFormBuildId()
- 9 core/modules/system/tests/src/Functional/Form/FormStoragePageCacheTest.php \Drupal\Tests\system\Functional\Form\FormStoragePageCacheTest::getFormBuildId()
- 8.9.x core/modules/system/tests/src/Functional/Form/FormStoragePageCacheTest.php \Drupal\Tests\system\Functional\Form\FormStoragePageCacheTest::getFormBuildId()
Return the build id of the current form.
2 calls to FormStoragePageCacheTest::getFormBuildId()
- FormStoragePageCacheTest::testRebuildFormStorageOnCachedPage in core/
modules/ system/ tests/ src/ Functional/ Form/ FormStoragePageCacheTest.php - Build-id is regenerated when rebuilding cached form.
- FormStoragePageCacheTest::testValidateFormStorageOnCachedPage in core/
modules/ system/ tests/ src/ Functional/ Form/ FormStoragePageCacheTest.php - Build-id is regenerated when validating cached form.
File
-
core/
modules/ system/ tests/ src/ Functional/ Form/ FormStoragePageCacheTest.php, line 42
Class
- FormStoragePageCacheTest
- Tests form storage from cached pages.
Namespace
Drupal\Tests\system\Functional\FormCode
protected function getFormBuildId() : string {
// Ensure the hidden 'form_build_id' field is unique.
$this->assertSession()
->elementsCount('xpath', '//input[@name="form_build_id"]', 1);
$form_build_id_element = $this->assertSession()
->hiddenFieldExists('form_build_id');
// Test that the autocomplete attribute is set to off to prevent Firefox and
// similar browsers from retaining the form build ID on browser reload.
// @todo Add actual testing that the form build ID is not retained once
// Firefox is included in automated testing in
// https://www.drupal.org/project/drupal/issues/3462680.
$this->assertSame('off', $form_build_id_element->getAttribute('autocomplete'));
return (string) $form_build_id_element->getAttribute('value');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.