You are here

protected function LingotekNodeMetatagsTranslationTest::createMetatagField in Lingotek Translation 8

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 src/Tests/LingotekNodeMetatagsTranslationTest.php
Sets up a Drupal site for running functional and integration tests.

File

src/Tests/LingotekNodeMetatagsTranslationTest.php, line 167

Class

LingotekNodeMetatagsTranslationTest
Tests translating a node with multiple locales including metatags.

Namespace

Drupal\lingotek\Tests

Code

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

  // Create a field with settings to validate.
  $fieldStorage = entity_create('field_storage_config', array(
    'field_name' => $field_name,
    'entity_type' => $entity_type,
    'type' => 'metatag',
  ));
  $fieldStorage
    ->save();
  $field = entity_create('field_config', array(
    'field_storage' => $fieldStorage,
    'bundle' => $bundle,
  ));
  $field
    ->save();
  entity_get_form_display($entity_type, $bundle, 'default')
    ->setComponent($field_name, array(
    'type' => 'metatag_firehose',
  ))
    ->save();
  entity_get_display($entity_type, $bundle, 'default')
    ->setComponent($field_name, array(
    'type' => 'metatag_empty_formatter',
  ))
    ->save();
}