function ActiveWorkspaceUpdateTest::setUp

Same name and namespace in other branches
  1. 9 core/modules/workspaces/tests/src/Functional/UpdateSystem/ActiveWorkspaceUpdateTest.php \Drupal\Tests\workspaces\Functional\UpdateSystem\ActiveWorkspaceUpdateTest::setUp()
  2. 8.9.x core/modules/workspaces/tests/src/Functional/UpdateSystem/ActiveWorkspaceUpdateTest.php \Drupal\Tests\workspaces\Functional\UpdateSystem\ActiveWorkspaceUpdateTest::setUp()
  3. 10 core/modules/workspaces/tests/src/Functional/UpdateSystem/ActiveWorkspaceUpdateTest.php \Drupal\Tests\workspaces\Functional\UpdateSystem\ActiveWorkspaceUpdateTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/workspaces/tests/src/Functional/UpdateSystem/ActiveWorkspaceUpdateTest.php, line 36

Class

ActiveWorkspaceUpdateTest
Tests that there is no active workspace during database updates.

Namespace

Drupal\Tests\workspaces\Functional\UpdateSystem

Code

protected function setUp() : void {
    parent::setUp();
    $this->setUpCurrentUser([], [
        'view any workspace',
    ]);
    $this->container
        ->get('module_installer')
        ->install([
        'workspace_update_test',
    ]);
    $this->rebuildContainer();
    // Ensure the workspace_update_test_post_update_check_active_workspace()
    // update runs.
    $existing_updates = \Drupal::keyValue('post_update')->get('existing_updates', []);
    $index = array_search('workspace_update_test_post_update_check_active_workspace', $existing_updates);
    unset($existing_updates[$index]);
    \Drupal::keyValue('post_update')->set('existing_updates', $existing_updates);
    // Create a valid workspace that can be used for testing.
    Workspace::create([
        'id' => 'test',
        'label' => 'Test',
    ])->save();
}

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