function WorkspaceTestUtilities::createAndActivateWorkspaceThroughUi

Same name in other branches
  1. 11.x core/modules/workspaces/tests/src/Functional/WorkspaceTestUtilities.php \Drupal\Tests\workspaces\Functional\WorkspaceTestUtilities::createAndActivateWorkspaceThroughUi()

Creates and activates a new Workspace through the UI.

Parameters

string $label: The label of the workspace to create.

string $id: The ID of the workspace to create.

string $parent: (optional) The ID of the parent workspace. Defaults to '_none'.

Return value

\Drupal\workspaces\WorkspaceInterface The workspace that was just created.

4 calls to WorkspaceTestUtilities::createAndActivateWorkspaceThroughUi()
WorkspaceBypassTest::testBypassOwnWorkspace in core/modules/workspaces/tests/src/Functional/WorkspaceBypassTest.php
Verifies that a user can edit anything in a workspace they own.
WorkspaceSwitcherTest::testSwitchingWorkspaces in core/modules/workspaces/tests/src/Functional/WorkspaceSwitcherTest.php
Tests switching workspace via the switcher block and admin page.
WorkspaceTest::testDeleteWorkspaceWithExistingContent in core/modules/workspaces/tests/src/Functional/WorkspaceTest.php
Verifies that a workspace with existing content may be deleted.
WorkspaceTest::testSpecialCharacters in core/modules/workspaces/tests/src/Functional/WorkspaceTest.php
Tests creating a workspace with special characters.

File

core/modules/workspaces/tests/src/Functional/WorkspaceTestUtilities.php, line 63

Class

WorkspaceTestUtilities
Utility methods for use in BrowserTestBase tests.

Namespace

Drupal\Tests\workspaces\Functional

Code

protected function createAndActivateWorkspaceThroughUi(string $label, string $id, string $parent = '_none') : WorkspaceInterface {
    $this->drupalGet('/admin/config/workflow/workspaces/add');
    $this->submitForm([
        'id' => $id,
        'label' => $label,
        'parent' => $parent,
    ], 'Save and switch');
    $this->getSession()
        ->getPage()
        ->hasContent("{$label} ({$id})");
    return Workspace::load($id);
}

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