You are here

protected function LingotekNodeMetatagsTranslationTest::createMetatagField in Lingotek Translation 3.1.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/LingotekNodeMetatagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeMetatagsTranslationTest::createMetatagField()
  2. 4.0.x tests/src/Functional/LingotekNodeMetatagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeMetatagsTranslationTest::createMetatagField()
  3. 3.0.x tests/src/Functional/LingotekNodeMetatagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeMetatagsTranslationTest::createMetatagField()
  4. 3.2.x tests/src/Functional/LingotekNodeMetatagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeMetatagsTranslationTest::createMetatagField()
  5. 3.3.x tests/src/Functional/LingotekNodeMetatagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeMetatagsTranslationTest::createMetatagField()
  6. 3.4.x tests/src/Functional/LingotekNodeMetatagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeMetatagsTranslationTest::createMetatagField()
  7. 3.5.x tests/src/Functional/LingotekNodeMetatagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeMetatagsTranslationTest::createMetatagField()
  8. 3.6.x tests/src/Functional/LingotekNodeMetatagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeMetatagsTranslationTest::createMetatagField()
  9. 3.7.x tests/src/Functional/LingotekNodeMetatagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeMetatagsTranslationTest::createMetatagField()
  10. 3.8.x tests/src/Functional/LingotekNodeMetatagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeMetatagsTranslationTest::createMetatagField()

Adds a metatag field.

Parameters

string $field_name: The field name.

$entity_type: The entity type.

$bundle: The bundle.

1 call to LingotekNodeMetatagsTranslationTest::createMetatagField()
LingotekNodeMetatagsTranslationTest::setUp in tests/src/Functional/LingotekNodeMetatagsTranslationTest.php

File

tests/src/Functional/LingotekNodeMetatagsTranslationTest.php, line 156

Class

LingotekNodeMetatagsTranslationTest
Tests translating a node with multiple locales including metatags.

Namespace

Drupal\Tests\lingotek\Functional

Code

protected function createMetatagField($field_name, $entity_type, $bundle) {

  // Create a field with settings to validate.
  $fieldStorage = \Drupal::entityTypeManager()
    ->getStorage('field_storage_config')
    ->create([
    'field_name' => $field_name,
    'entity_type' => $entity_type,
    'type' => 'metatag',
  ]);
  $fieldStorage
    ->save();
  $field = \Drupal::entityTypeManager()
    ->getStorage('field_config')
    ->create([
    'field_storage' => $fieldStorage,
    'bundle' => $bundle,
  ]);
  $field
    ->save();
  EntityFormDisplay::load($entity_type . '.' . $bundle . '.' . 'default')
    ->setComponent($field_name, [
    'type' => 'metatag_firehose',
  ])
    ->save();
  EntityViewDisplay::load($entity_type . '.' . $bundle . '.' . 'default')
    ->setComponent($field_name, [
    'type' => 'metatag_empty_formatter',
  ])
    ->save();
}