function WorkspaceTestTrait::createWorkspaceHierarchy

Same name in other branches
  1. 9 core/modules/workspaces/tests/src/Kernel/WorkspaceTestTrait.php \Drupal\Tests\workspaces\Kernel\WorkspaceTestTrait::createWorkspaceHierarchy()
  2. 8.9.x core/modules/workspaces/tests/src/Kernel/WorkspaceTestTrait.php \Drupal\Tests\workspaces\Kernel\WorkspaceTestTrait::createWorkspaceHierarchy()
  3. 10 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
2 calls to WorkspaceTestTrait::createWorkspaceHierarchy()
WorkspaceIntegrationTest::testWorkspaceHierarchy in core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php
Tests entity tracking in workspace descendants.
WorkspaceMergerTest::testWorkspaceMerger in core/modules/workspaces/tests/src/Kernel/WorkspaceMergerTest.php
Tests workspace merging.

File

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

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();
}

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