You are here

protected function WorkspaceTestTrait::initializeWorkspacesModule in Drupal 8

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

Enables the Workspaces module and creates two workspaces.

14 calls to WorkspaceTestTrait::initializeWorkspacesModule()
EntityReferenceSupportedNewEntitiesConstraintValidatorTest::setUp in core/modules/workspaces/tests/src/Kernel/EntityReferenceSupportedNewEntitiesConstraintValidatorTest.php
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.
WorkspaceIntegrationTest::testEntityQueryRelationship in core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php
Tests the Entity Query relationship API with workspaces.

... See full list

File

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

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',
  ]);

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