function WorkspaceTestUtilities::createWorkspaceThroughUi

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

Creates 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.

16 calls to WorkspaceTestUtilities::createWorkspaceThroughUi()
PathWorkspacesTest::testPathAliasesWithTranslation in core/modules/workspaces/tests/src/Functional/PathWorkspacesTest.php
Tests path aliases with workspaces for translatable nodes.
WorkspaceConcurrentEditingTest::testConcurrentEditing in core/modules/workspaces/tests/src/Functional/WorkspaceConcurrentEditingTest.php
Tests editing a node in multiple workspaces.
WorkspaceContentModerationIntegrationTest::setUp in core/modules/content_moderation/tests/src/Functional/WorkspaceContentModerationIntegrationTest.php
Sets the test up.
WorkspaceEntityDeleteTest::testEntityDelete in core/modules/workspaces/tests/src/Functional/WorkspaceEntityDeleteTest.php
Test entity deletion with workspaces.
WorkspaceMenuLinkContentIntegrationTest::testWorkspacesWithCustomMenuLinks in core/modules/workspaces/tests/src/Functional/WorkspaceMenuLinkContentIntegrationTest.php
Tests custom menu links in non-default workspaces.

... See full list

File

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

Class

WorkspaceTestUtilities
Utility methods for use in BrowserTestBase tests.

Namespace

Drupal\Tests\workspaces\Functional

Code

protected function createWorkspaceThroughUi(?string $label = NULL, ?string $id = NULL, string $parent = '_none') {
  $id ??= $this->randomMachineName();
  $label ??= $this->randomString();
  $this->drupalGet('/admin/config/workflow/workspaces/add');
  $this->submitForm([
    'id' => $id,
    'label' => $label,
    'parent' => $parent,
  ], 'Save');
  $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.