public function FormStoragePageCacheTest::testRebuildFormStorageOnCachedPage in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/system/src/Tests/Form/FormStoragePageCacheTest.php \Drupal\system\Tests\Form\FormStoragePageCacheTest::testRebuildFormStorageOnCachedPage()
Build-id is regenerated when rebuilding cached form.
File
- core/
modules/ system/ src/ Tests/ Form/ FormStoragePageCacheTest.php, line 93 - Contains \Drupal\system\Tests\Form\FormStoragePageCacheTest.
Class
- FormStoragePageCacheTest
- Tests form storage from cached pages.
Namespace
Drupal\system\Tests\FormCode
public function testRebuildFormStorageOnCachedPage() {
$this
->drupalGet('form-test/form-storage-page-cache');
$this
->assertEqual($this
->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Page was not cached.');
$this
->assertText('No old build id', 'No old build id on the page');
$build_id_initial = $this
->getFormBuildId();
// Trigger rebuild, should regenerate build id. When a submit handler
// triggers a rebuild, the form is built twice in the same POST request,
// and during the second build, there is an old build ID, but because the
// form is not cached during the initial GET request, it is different from
// that initial build ID.
$edit = [
'title' => 'something',
];
$this
->drupalPostForm(NULL, $edit, 'Rebuild');
$this
->assertNoText('No old build id', 'There is no old build id on the page.');
$this
->assertNoText($build_id_initial, 'The old build id is not the initial build id.');
$build_id_first_rebuild = $this
->getFormBuildId();
$this
->assertNotEqual($build_id_initial, $build_id_first_rebuild, 'Build id changes on first rebuild.');
// Trigger subsequent rebuild, should regenerate the build id again.
$edit = [
'title' => 'something',
];
$this
->drupalPostForm(NULL, $edit, 'Rebuild');
$this
->assertText($build_id_first_rebuild, 'First build id as old build id on the page');
$build_id_second_rebuild = $this
->getFormBuildId();
$this
->assertNotEqual($build_id_first_rebuild, $build_id_second_rebuild, 'Build id changes on second rebuild.');
}