function ContentTranslationLinkTagTest::createTranslatableEntity

Same name and namespace in other branches
  1. 9 core/modules/content_translation/tests/src/Functional/ContentTranslationLinkTagTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationLinkTagTest::createTranslatableEntity()
  2. 10 core/modules/content_translation/tests/src/Functional/ContentTranslationLinkTagTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationLinkTagTest::createTranslatableEntity()
  3. 11.x core/modules/content_translation/tests/src/Functional/ContentTranslationLinkTagTest.php \Drupal\Tests\content_translation\Functional\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 70

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.