You are here

protected function WorkspaceIntegrationTest::setUp in Drupal 9

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

Overrides KernelTestBase::setUp

File

core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php, line 76

Class

WorkspaceIntegrationTest
Tests a complete publishing scenario across different workspaces.

Namespace

Drupal\Tests\workspaces\Kernel

Code

protected function setUp() : void {
  parent::setUp();
  $this->entityTypeManager = \Drupal::entityTypeManager();
  $this
    ->installEntitySchema('entity_test_mulrev');
  $this
    ->installEntitySchema('entity_test_mulrevpub');
  $this
    ->installEntitySchema('entity_test_no_label');
  $this
    ->installEntitySchema('node');
  $this
    ->installEntitySchema('user');
  $this
    ->installConfig([
    'filter',
    'node',
    'system',
    'language',
    'content_translation',
  ]);
  $this
    ->installSchema('system', [
    'sequences',
  ]);
  $this
    ->installSchema('node', [
    'node_access',
  ]);
  $language = ConfigurableLanguage::createFromLangcode('de');
  $language
    ->save();
  $this
    ->createContentType([
    'type' => 'page',
  ]);
  $this
    ->setCurrentUser($this
    ->createUser([
    'administer nodes',
  ]));
  $this->container
    ->get('content_translation.manager')
    ->setEnabled('node', 'page', TRUE);

  // Create two nodes, a published and an unpublished one, so we can test the
  // behavior of the module with default/existing content.
  $this->createdTimestamp = \Drupal::time()
    ->getRequestTime();
  $this->nodes[] = $this
    ->createNode([
    'title' => 'live - 1 - r1 - published',
    'body' => 'node 1',
    'created' => $this->createdTimestamp++,
    'status' => TRUE,
  ]);
  $this->nodes[] = $this
    ->createNode([
    'title' => 'live - 2 - r2 - unpublished',
    'body' => 'node 2',
    'created' => $this->createdTimestamp++,
    'status' => FALSE,
  ]);
  $translation = $this->nodes[0]
    ->addTranslation('de');
  $translation
    ->setTitle('live - 1 - r1 - published - de');
  $translation
    ->save();
}