public function EntityReferenceItemTest::setUp

Sets up the test.

Overrides FieldUnitTestBase::setUp

File

drupal/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceItemTest.php, line 38
Contains \Drupal\entity_reference\Tests\EntityReferenceItemTest.

Class

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

Namespace

Drupal\entity_reference\Tests

Code

public function setUp() {
  parent::setUp();
  $this
    ->installSchema('taxonomy', 'taxonomy_term_data');
  $this
    ->installSchema('taxonomy', 'taxonomy_term_hierarchy');
  $vocabulary = entity_create('taxonomy_vocabulary', array(
    'name' => $this
      ->randomName(),
    'vid' => drupal_strtolower($this
      ->randomName()),
    'langcode' => Language::LANGCODE_NOT_SPECIFIED,
  ));
  $vocabulary
    ->save();
  $this->term = entity_create('taxonomy_term', array(
    'name' => $this
      ->randomName(),
    'vid' => $vocabulary
      ->id(),
    'langcode' => Language::LANGCODE_NOT_SPECIFIED,
  ));
  $this->term
    ->save();

  // Use the util to create an instance.
  entity_reference_create_instance('entity_test', 'entity_test', 'field_test_taxonomy', 'Test entity reference', 'taxonomy_term');
}