You are here

protected function EntityReferenceItemTest::setUp in Zircon Profile 8

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

Sets up the test.

Overrides FieldUnitTestBase::setUp

File

core/modules/field/src/Tests/EntityReference/EntityReferenceItemTest.php, line 69
Contains \Drupal\field\Tests\EntityReference\EntityReferenceItemTest.

Class

EntityReferenceItemTest
Tests the new entity API for the entity reference field type.

Namespace

Drupal\field\Tests\EntityReference

Code

protected function setUp() {
  parent::setUp();
  $this
    ->installEntitySchema('entity_test_string_id');
  $this
    ->installEntitySchema('taxonomy_term');
  $this
    ->installEntitySchema('node');
  $this
    ->installEntitySchema('comment');
  $this
    ->installEntitySchema('file');
  $this
    ->installSchema('comment', [
    'comment_entity_statistics',
  ]);
  $this->vocabulary = entity_create('taxonomy_vocabulary', array(
    'name' => $this
      ->randomMachineName(),
    'vid' => Unicode::strtolower($this
      ->randomMachineName()),
    'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
  ));
  $this->vocabulary
    ->save();
  $this->term = entity_create('taxonomy_term', array(
    'name' => $this
      ->randomMachineName(),
    'vid' => $this->vocabulary
      ->id(),
    'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
  ));
  $this->term
    ->save();
  $this->entityStringId = EntityTestStringId::create([
    'id' => $this
      ->randomMachineName(),
  ]);
  $this->entityStringId
    ->save();

  // Use the util to create an instance.
  $this
    ->createEntityReferenceField('entity_test', 'entity_test', 'field_test_taxonomy_term', 'Test content entity reference', 'taxonomy_term');
  $this
    ->createEntityReferenceField('entity_test', 'entity_test', 'field_test_entity_test_string_id', 'Test content entity reference with string ID', 'entity_test_string_id');
  $this
    ->createEntityReferenceField('entity_test', 'entity_test', 'field_test_taxonomy_vocabulary', 'Test config entity reference', 'taxonomy_vocabulary');
  $this
    ->createEntityReferenceField('entity_test', 'entity_test', 'field_test_node', 'Test node entity reference', 'node');
  $this
    ->createEntityReferenceField('entity_test', 'entity_test', 'field_test_user', 'Test user entity reference', 'user');
  $this
    ->createEntityReferenceField('entity_test', 'entity_test', 'field_test_comment', 'Test comment entity reference', 'comment');
  $this
    ->createEntityReferenceField('entity_test', 'entity_test', 'field_test_file', 'Test file entity reference', 'file');
}