function WorkspaceTestTrait::initializeWorkspacesModule

Same name and namespace in other branches
  1. 9 core/modules/workspaces/tests/src/Kernel/WorkspaceTestTrait.php \Drupal\Tests\workspaces\Kernel\WorkspaceTestTrait::initializeWorkspacesModule()
  2. 8.9.x core/modules/workspaces/tests/src/Kernel/WorkspaceTestTrait.php \Drupal\Tests\workspaces\Kernel\WorkspaceTestTrait::initializeWorkspacesModule()
  3. 10 core/modules/workspaces/tests/src/Kernel/WorkspaceTestTrait.php \Drupal\Tests\workspaces\Kernel\WorkspaceTestTrait::initializeWorkspacesModule()

Enables the Workspaces module and creates two workspaces.

17 calls to WorkspaceTestTrait::initializeWorkspacesModule()
EntityReferenceSupportedNewEntitiesConstraintValidatorTest::setUp in core/modules/workspaces/tests/src/Kernel/EntityReferenceSupportedNewEntitiesConstraintValidatorTest.php
WorkspaceIntegrationTest::testCliPublishing in core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php
Tests workspace publishing as anonymous user, simulating a CLI request.
WorkspaceIntegrationTest::testDisallowedEntityCreateInNonDefaultWorkspace in core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php
Tests CREATE operations for unsupported entity types.
WorkspaceIntegrationTest::testDisallowedEntityDeleteInNonDefaultWorkspace in core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php
Tests DELETE operations for unsupported entity types.
WorkspaceIntegrationTest::testDisallowedEntityUpdateInNonDefaultWorkspace in core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php
Tests UPDATE operations for unsupported entity types.

... See full list

File

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

Class

WorkspaceTestTrait
A trait with common workspaces testing functionality.

Namespace

Drupal\Tests\workspaces\Kernel

Code

protected function initializeWorkspacesModule() {
    // Enable the Workspaces module here instead of the static::$modules array
    // so we can test it with default content.
    $this->enableModules([
        'workspaces',
    ]);
    $this->container = \Drupal::getContainer();
    $this->entityTypeManager = \Drupal::entityTypeManager();
    $this->workspaceManager = \Drupal::service('workspaces.manager');
    $this->installEntitySchema('workspace');
    $this->installSchema('workspaces', [
        'workspace_association',
    ]);
    // Install the entity schema for supported entity types to ensure that the
    // 'workspace' revision metadata field gets created.
    foreach (array_keys(\Drupal::service('workspaces.information')->getSupportedEntityTypes()) as $entity_type_id) {
        $this->installEntitySchema($entity_type_id);
    }
    // Create two workspaces by default, 'live' and 'stage'.
    $this->workspaces['live'] = Workspace::create([
        'id' => 'live',
        'label' => 'Live',
    ]);
    $this->workspaces['live']
        ->save();
    $this->workspaces['stage'] = Workspace::create([
        'id' => 'stage',
        'label' => 'Stage',
    ]);
    $this->workspaces['stage']
        ->save();
    $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));
}

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