You are here

protected function EntityReferenceFieldTranslatedReferenceViewTest::setUpEntityReferenceField in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/field/src/Tests/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php \Drupal\field\Tests\EntityReference\EntityReferenceFieldTranslatedReferenceViewTest::setUpEntityReferenceField()

Adds term reference field for the article content type.

1 call to EntityReferenceFieldTranslatedReferenceViewTest::setUpEntityReferenceField()
EntityReferenceFieldTranslatedReferenceViewTest::setUp in core/modules/field/src/Tests/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php
Sets up a Drupal site for running functional and integration tests.

File

core/modules/field/src/Tests/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php, line 208
Contains \Drupal\field\Tests\EntityReference\EntityReferenceFieldTranslatedReferenceViewTest.

Class

EntityReferenceFieldTranslatedReferenceViewTest
Tests the translation of entity reference field display on nodes.

Namespace

Drupal\field\Tests\EntityReference

Code

protected function setUpEntityReferenceField() {
  entity_create('field_storage_config', array(
    'field_name' => $this->referenceFieldName,
    'entity_type' => $this->testEntityTypeName,
    'type' => 'entity_reference',
    'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
    'translatable' => $this->translatable,
    'settings' => array(
      'allowed_values' => array(
        array(
          'target_type' => $this->testEntityTypeName,
        ),
      ),
    ),
  ))
    ->save();
  entity_create('field_config', array(
    'field_name' => $this->referenceFieldName,
    'bundle' => $this->referrerType
      ->id(),
    'entity_type' => $this->testEntityTypeName,
  ))
    ->save();
  entity_get_form_display($this->testEntityTypeName, $this->referrerType
    ->id(), 'default')
    ->setComponent($this->referenceFieldName, array(
    'type' => 'entity_reference_autocomplete',
  ))
    ->save();
  entity_get_display($this->testEntityTypeName, $this->referrerType
    ->id(), 'default')
    ->setComponent($this->referenceFieldName, array(
    'type' => 'entity_reference_label',
  ))
    ->save();
}