You are here

public function ActiveWorkspaceUpdateTest::testActiveWorkspaceDuringUpdate in Drupal 8

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

Tests that there is no active workspace during database updates.

File

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

Class

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

Namespace

Drupal\Tests\workspaces\Functional\UpdateSystem

Code

public function testActiveWorkspaceDuringUpdate() {

  /** @var \Drupal\workspaces\WorkspaceManagerInterface $workspace_manager */
  $workspace_manager = \Drupal::service('workspaces.manager');

  // Check that we have an active workspace before running the updates.
  $this
    ->assertTrue($workspace_manager
    ->hasActiveWorkspace());
  $this
    ->assertEquals('test', $workspace_manager
    ->getActiveWorkspace()
    ->id());
  $this
    ->runUpdates();

  // Check that we didn't have an active workspace while running the updates.
  // @see workspace_update_test_post_update_check_active_workspace()
  $this
    ->assertFalse(\Drupal::state()
    ->get('workspace_update_test.has_active_workspace'));

  // Check that we have an active workspace after running the updates.
  $workspace_manager = \Drupal::service('workspaces.manager');
  $this
    ->assertTrue($workspace_manager
    ->hasActiveWorkspace());
  $this
    ->assertEquals('test', $workspace_manager
    ->getActiveWorkspace()
    ->id());
}