/** * Sets up the test. */ 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->installSchema('node', ['node_access']); $this->vocabulary = Vocabulary::create(['name' => $this->randomMachineName(), 'vid' => Unicode::strtolower($this->randomMachineName()), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED]); $this->vocabulary->save(); $this->term = Term::create(['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', 'default', [], FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED); $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'); }
/** * Sets up the test. */ protected function setUp() { parent::setUp(); $this->installEntitySchema('entity_test_string_id'); $this->installEntitySchema('taxonomy_term'); $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'); }