function EarlyDateTest::setUp

Same name in other branches
  1. 9 core/modules/taxonomy/tests/src/Functional/EarlyDateTest.php \Drupal\Tests\taxonomy\Functional\EarlyDateTest::setUp()
  2. 8.9.x core/modules/taxonomy/tests/src/Functional/EarlyDateTest.php \Drupal\Tests\taxonomy\Functional\EarlyDateTest::setUp()
  3. 11.x core/modules/taxonomy/tests/src/Functional/EarlyDateTest.php \Drupal\Tests\taxonomy\Functional\EarlyDateTest::setUp()

Overrides TaxonomyTestBase::setUp

File

core/modules/taxonomy/tests/src/Functional/EarlyDateTest.php, line 31

Class

EarlyDateTest
Posts an article with a taxonomy term and a date prior to 1970.

Namespace

Drupal\Tests\taxonomy\Functional

Code

protected function setUp() : void {
    parent::setUp();
    // Create a tags vocabulary for the 'article' content type.
    $vocabulary = Vocabulary::create([
        'name' => 'Tags',
        'vid' => 'tags',
    ]);
    $vocabulary->save();
    $field_name = 'field_' . $vocabulary->id();
    $handler_settings = [
        'target_bundles' => [
            $vocabulary->id() => $vocabulary->id(),
        ],
        'auto_create' => TRUE,
    ];
    $this->createEntityReferenceField('node', 'article', $field_name, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
    \Drupal::service('entity_display.repository')->getFormDisplay('node', 'article')
        ->setComponent($field_name, [
        'type' => 'entity_reference_autocomplete_tags',
    ])
        ->save();
    $this->drupalLogin($this->drupalCreateUser([
        'administer taxonomy',
        'administer nodes',
        'bypass node access',
    ]));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.