Chris@14: 'Tags', Chris@14: 'vid' => 'tags', Chris@14: ]); Chris@14: $vocabulary->save(); Chris@14: $field_name = 'field_' . $vocabulary->id(); Chris@14: Chris@14: $handler_settings = [ Chris@14: 'target_bundles' => [ Chris@14: $vocabulary->id() => $vocabulary->id(), Chris@14: ], Chris@14: 'auto_create' => TRUE, Chris@14: ]; Chris@14: $this->createEntityReferenceField('node', 'article', $field_name, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED); Chris@14: Chris@14: entity_get_form_display('node', 'article', 'default') Chris@14: ->setComponent($field_name, [ Chris@14: 'type' => 'entity_reference_autocomplete_tags', Chris@14: ]) Chris@14: ->save(); Chris@14: Chris@14: $this->drupalLogin($this->drupalCreateUser(['administer taxonomy', 'administer nodes', 'bypass node access'])); Chris@14: } Chris@14: Chris@14: /** Chris@14: * Test taxonomy functionality with nodes prior to 1970. Chris@14: */ Chris@14: public function testTaxonomyEarlyDateNode() { Chris@14: // Posts an article with a taxonomy term and a date prior to 1970. Chris@14: $date = new DrupalDateTime('1969-01-01 00:00:00'); Chris@14: $edit = []; Chris@14: $edit['title[0][value]'] = $this->randomMachineName(); Chris@14: $edit['created[0][value][date]'] = $date->format('Y-m-d'); Chris@14: $edit['created[0][value][time]'] = $date->format('H:i:s'); Chris@14: $edit['body[0][value]'] = $this->randomMachineName(); Chris@14: $edit['field_tags[target_id]'] = $this->randomMachineName(); Chris@14: $this->drupalPostForm('node/add/article', $edit, t('Save')); Chris@14: // Checks that the node has been saved. Chris@14: $node = $this->drupalGetNodeByTitle($edit['title[0][value]']); Chris@14: $this->assertEqual($node->getCreatedTime(), $date->getTimestamp(), 'Legacy node was saved with the right date.'); Chris@14: } Chris@14: Chris@14: }