You are here

public function WorkspaceSwitcherTest::testSwitchingWorkspaces in Workspace 8.2

Same name and namespace in other branches
  1. 8 tests/src/Functional/WorkspaceSwitcherTest.php \Drupal\Tests\workspace\Functional\WorkspaceSwitcherTest::testSwitchingWorkspaces()

Test switching workspace via the switcher block and admin page.

File

tests/src/Functional/WorkspaceSwitcherTest.php, line 24

Class

WorkspaceSwitcherTest
Tests workspace switching functionality.

Namespace

Drupal\Tests\workspace\Functional

Code

public function testSwitchingWorkspaces() {
  $permissions = [
    'create workspace',
    'edit own workspace',
    'view own workspace',
    'bypass entity access own workspace',
  ];
  $this
    ->setupWorkspaceSwitcherBlock();
  $mayer = $this
    ->drupalCreateUser($permissions);
  $this
    ->drupalLogin($mayer);
  $vultures = $this
    ->createWorkspaceThroughUi('Vultures', 'vultures');
  $this
    ->switchToWorkspace($vultures);
  $gravity = $this
    ->createWorkspaceThroughUi('Gravity', 'gravity');
  $this
    ->drupalGet('/admin/config/workflow/workspace/manage/' . $gravity
    ->id() . '/activate');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $page = $this
    ->getSession()
    ->getPage();
  $page
    ->findButton('Confirm')
    ->click();
  $page
    ->findLink($gravity
    ->label());
}