You are here

protected function WorkspaceTestUtilities::createWorkspaceThroughUi in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/workspaces/tests/src/Functional/WorkspaceTestUtilities.php \Drupal\Tests\workspaces\Functional\WorkspaceTestUtilities::createWorkspaceThroughUi()
  2. 9 core/modules/workspaces/tests/src/Functional/WorkspaceTestUtilities.php \Drupal\Tests\workspaces\Functional\WorkspaceTestUtilities::createWorkspaceThroughUi()

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

File

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

Class

WorkspaceTestUtilities
Utility methods for use in BrowserTestBase tests.

Namespace

Drupal\Tests\workspaces\Functional

Code

protected function createWorkspaceThroughUi($label, $id, $parent = '_none') {
  $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);
}