You are here

protected function LegacyTest::setUp in Zircon Profile 8

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

Sets up a Drupal site for running functional and integration tests.

Installs Drupal with the installation profile specified in \Drupal\simpletest\WebTestBase::$profile into the prefixed database.

Afterwards, installs any additional modules specified in the static \Drupal\simpletest\WebTestBase::$modules property of each class in the class hierarchy.

After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.

Overrides TaxonomyTestBase::setUp

File

core/modules/taxonomy/src/Tests/LegacyTest.php, line 27
Contains \Drupal\taxonomy\Tests\LegacyTest.

Class

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

Namespace

Drupal\taxonomy\Tests

Code

protected function setUp() {
  parent::setUp();

  // Create a tags vocabulary for the 'article' content type.
  $vocabulary = entity_create('taxonomy_vocabulary', array(
    'name' => 'Tags',
    'vid' => 'tags',
  ));
  $vocabulary
    ->save();
  $field_name = 'field_' . $vocabulary
    ->id();
  $handler_settings = array(
    'target_bundles' => array(
      $vocabulary
        ->id() => $vocabulary
        ->id(),
    ),
    'auto_create' => TRUE,
  );
  $this
    ->createEntityReferenceField('node', 'article', $field_name, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
  entity_get_form_display('node', 'article', 'default')
    ->setComponent($field_name, array(
    'type' => 'entity_reference_autocomplete_tags',
  ))
    ->save();
  $this
    ->drupalLogin($this
    ->drupalCreateUser([
    'administer taxonomy',
    'administer nodes',
    'bypass node access',
  ]));
}