function WorkspaceTestUtilities::createAndActivateWorkspaceThroughUi

Same name and namespace in other branches
  1. 10 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|null $label: The label of the workspace to create.

string|null $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.

8 calls to WorkspaceTestUtilities::createAndActivateWorkspaceThroughUi()
PathWorkspacesTest::testPathAliases in core/modules/workspaces/tests/src/Functional/PathWorkspacesTest.php
Tests path aliases with workspaces.
PathWorkspacesTest::testPathAliasesUserSwitch in core/modules/workspaces/tests/src/Functional/PathWorkspacesTest.php
Tests path aliases with workspaces and user switching.
WorkspaceBypassTest::testBypassOwnWorkspace in core/modules/workspaces/tests/src/Functional/WorkspaceBypassTest.php
Verifies that a user can edit anything in a workspace they own.
WorkspaceEntityDeleteTest::testNodeDeleteWithBypassAccessPermission in core/modules/workspaces/tests/src/Functional/WorkspaceEntityDeleteTest.php
Test node deletion with workspaces and the 'bypass node access' permission.
WorkspaceFormValidationTest::testValidateLimitErrors in core/modules/workspaces/tests/src/Functional/WorkspaceFormValidationTest.php
Tests partial form validation through #limit_validation_errors.

... See full list

File

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

Class

WorkspaceTestUtilities
Utility methods for use in BrowserTestBase tests.

Namespace

Drupal\Tests\workspaces\Functional

Code

protected function createAndActivateWorkspaceThroughUi(?string $label = NULL, ?string $id = NULL, string $parent = '_none') : WorkspaceInterface {
  $id ??= $this->randomMachineName();
  $label ??= $this->randomString();
  $this->drupalGet('/admin/config/workflow/workspaces/add');
  $this->submitForm([
    'id' => $id,
    'label' => $label,
    'parent' => $parent,
  ], 'Save and switch');
  $this->getSession()
    ->getPage()
    ->hasContent("{$label} ({$id})");
  // Keep the test runner in sync with the system under test.
  $workspace = Workspace::load($id);
  \Drupal::service('workspaces.manager')->setActiveWorkspace($workspace);
  return $workspace;
}

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