function WorkspaceIntegrationTest::testFormCacheForEntityForms

Same name and namespace in other branches
  1. 11.x core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php \Drupal\Tests\workspaces\Kernel\WorkspaceIntegrationTest::testFormCacheForEntityForms()
  2. 9 core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php \Drupal\Tests\workspaces\Kernel\WorkspaceIntegrationTest::testFormCacheForEntityForms()
  3. 8.9.x core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php \Drupal\Tests\workspaces\Kernel\WorkspaceIntegrationTest::testFormCacheForEntityForms()

Tests that entity forms can be stored in the form cache.

File

core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php, line 1052

Class

WorkspaceIntegrationTest
Tests a complete publishing scenario across different workspaces.

Namespace

Drupal\Tests\workspaces\Kernel

Code

public function testFormCacheForEntityForms() : void {
  $this->initializeWorkspacesModule();
  $this->switchToWorkspace('stage');
  $form_builder = $this->container
    ->get('form_builder');
  $form = $this->entityTypeManager
    ->getFormObject('entity_test_mulrevpub', 'default');
  $form->setEntity(EntityTestMulRevPub::create([]));
  $form_state = new FormState();
  $built_form = $form_builder->buildForm($form, $form_state);
  $form_builder->setCache($built_form['#build_id'], $built_form, $form_state);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.