You are here

protected function ContentTranslationTestBase::setupTestFields in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/content_translation/src/Tests/ContentTranslationTestBase.php \Drupal\content_translation\Tests\ContentTranslationTestBase::setupTestFields()

Creates the test fields.

1 call to ContentTranslationTestBase::setupTestFields()
ContentTranslationTestBase::setUp in core/modules/content_translation/src/Tests/ContentTranslationTestBase.php
Sets up a Drupal site for running functional and integration tests.
1 method overrides ContentTranslationTestBase::setupTestFields()
ContentTranslationSyncImageTest::setupTestFields in core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php
Creates the test image field.

File

core/modules/content_translation/src/Tests/ContentTranslationTestBase.php, line 182
Contains \Drupal\content_translation\Tests\ContentTranslationTestBase.

Class

ContentTranslationTestBase
Base class for content translation tests.

Namespace

Drupal\content_translation\Tests

Code

protected function setupTestFields() {
  if (empty($this->fieldName)) {
    $this->fieldName = 'field_test_et_ui_test';
  }
  entity_create('field_storage_config', array(
    'field_name' => $this->fieldName,
    'type' => 'string',
    'entity_type' => $this->entityTypeId,
    'cardinality' => 1,
  ))
    ->save();
  entity_create('field_config', array(
    'entity_type' => $this->entityTypeId,
    'field_name' => $this->fieldName,
    'bundle' => $this->bundle,
    'label' => 'Test translatable text-field',
  ))
    ->save();
  entity_get_form_display($this->entityTypeId, $this->bundle, 'default')
    ->setComponent($this->fieldName, array(
    'type' => 'string_textfield',
    'weight' => 0,
  ))
    ->save();
}