function ContentTranslationLinkTagTest::createTranslatableEntity

Create a test entity with translations.

Return value

\Drupal\Core\Entity\EntityInterface An entity with translations.

1 call to ContentTranslationLinkTagTest::createTranslatableEntity()
ContentTranslationLinkTagTest::testCanonicalAlternateTags in core/modules/content_translation/tests/src/Functional/ContentTranslationLinkTagTest.php
Tests alternate link tag found for entity types with canonical links.

File

core/modules/content_translation/tests/src/Functional/ContentTranslationLinkTagTest.php, line 71

Class

ContentTranslationLinkTagTest
Tests whether canonical link tags are present for content entities.

Namespace

Drupal\Tests\content_translation\Functional

Code

protected function createTranslatableEntity() {
  $entity = EntityTestMul::create([
    'label' => $this->randomString(),
  ]);
  // Create translations for non default languages.
  foreach ($this->langcodes as $langcode) {
    $entity->addTranslation($langcode, [
      'label' => $this->randomString(),
    ]);
  }
  $entity->save();
  return $entity;
}

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