function WorkspaceAssociationTest::setUp

Same name and namespace in other branches
  1. 10 core/modules/workspaces/tests/src/Kernel/WorkspaceAssociationTest.php \Drupal\Tests\workspaces\Kernel\WorkspaceAssociationTest::setUp()

Overrides KernelTestBase::setUp

File

core/modules/workspaces/tests/src/Kernel/WorkspaceAssociationTest.php, line 50

Class

WorkspaceAssociationTest
Tests workspace associations.

Namespace

Drupal\Tests\workspaces\Kernel

Code

protected function setUp() : void {
    parent::setUp();
    $this->entityTypeManager = \Drupal::entityTypeManager();
    $this->installEntitySchema('node');
    $this->installEntitySchema('user');
    $this->installEntitySchema('workspace');
    $this->installConfig([
        'filter',
        'node',
        'system',
    ]);
    $this->installSchema('node', [
        'node_access',
    ]);
    $this->installSchema('workspaces', [
        'workspace_association',
    ]);
    $this->createContentType([
        'type' => 'article',
    ]);
    $permissions = array_intersect([
        'administer nodes',
        'create workspace',
        'edit any workspace',
        'view any workspace',
    ], array_keys($this->container
        ->get('user.permissions')
        ->getPermissions()));
    $this->setCurrentUser($this->createUser($permissions));
    $this->workspaces['stage'] = Workspace::create([
        'id' => 'stage',
        'label' => 'Stage',
    ]);
    $this->workspaces['stage']
        ->save();
    $this->workspaces['dev'] = Workspace::create([
        'id' => 'dev',
        'parent' => 'stage',
        'label' => 'Dev',
    ]);
    $this->workspaces['dev']
        ->save();
}

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