You are here

protected function ModerationLocaleTest::loadTranslation in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/content_moderation/tests/src/Functional/ModerationLocaleTest.php \Drupal\Tests\content_moderation\Functional\ModerationLocaleTest::loadTranslation()

Loads the node translation for the specified language.

Parameters

\Drupal\node\NodeInterface $node: A node object.

string $langcode: The translation language code.

Return value

\Drupal\node\NodeInterface The node translation object.

1 call to ModerationLocaleTest::loadTranslation()
ModerationLocaleTest::testLanguageIndependentContentModeration in core/modules/content_moderation/tests/src/Functional/ModerationLocaleTest.php
Tests that individual translations can be moderated independently.

File

core/modules/content_moderation/tests/src/Functional/ModerationLocaleTest.php, line 487

Class

ModerationLocaleTest
Test content_moderation functionality with localization and translation.

Namespace

Drupal\Tests\content_moderation\Functional

Code

protected function loadTranslation(NodeInterface $node, $langcode) {

  /** @var \Drupal\node\NodeStorageInterface $storage */
  $storage = $this->container
    ->get('entity_type.manager')
    ->getStorage('node');

  // Explicitly invalidate the cache for that node, as the call below is
  // statically cached.
  $storage
    ->resetCache([
    $node
      ->id(),
  ]);

  /** @var \Drupal\node\NodeInterface $node */
  $node = $storage
    ->loadRevision($storage
    ->getLatestRevisionId($node
    ->id()));
  return $node
    ->getTranslation($langcode);
}