You are here

protected function WorkspaceTestTrait::createWorkspaceHierarchy in Drupal 10

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

Creates a test workspace hierarchy.

The full hierarchy including the default workspaces 'live' and 'stage' is:

live

  • stage

    • dev

      • local_1
      • local_2
  • qa

File

core/modules/workspaces/tests/src/Kernel/WorkspaceTestTrait.php, line 79

Class

WorkspaceTestTrait
A trait with common workspaces testing functionality.

Namespace

Drupal\Tests\workspaces\Kernel

Code

protected function createWorkspaceHierarchy() {
  $this->workspaces['dev'] = Workspace::create([
    'id' => 'dev',
    'parent' => 'stage',
    'label' => 'dev',
  ]);
  $this->workspaces['dev']
    ->save();
  $this->workspaces['local_1'] = Workspace::create([
    'id' => 'local_1',
    'parent' => 'dev',
    'label' => 'local_1',
  ]);
  $this->workspaces['local_1']
    ->save();
  $this->workspaces['local_2'] = Workspace::create([
    'id' => 'local_2',
    'parent' => 'dev',
    'label' => 'local_2',
  ]);
  $this->workspaces['local_2']
    ->save();
  $this->workspaces['qa'] = Workspace::create([
    'id' => 'qa',
    'parent' => 'live',
    'label' => 'qa',
  ]);
  $this->workspaces['qa']
    ->save();
}