You are here

protected function QuickEditAutocompleteTermTest::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php \Drupal\quickedit\Tests\QuickEditAutocompleteTermTest::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 WebTestBase::setUp

File

core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php, line 74
Contains \Drupal\quickedit\Tests\QuickEditAutocompleteTermTest.

Class

QuickEditAutocompleteTermTest
Tests in-place editing of autocomplete tags.

Namespace

Drupal\quickedit\Tests

Code

protected function setUp() {
  parent::setUp();
  $this
    ->drupalCreateContentType(array(
    'type' => 'article',
  ));

  // Create the vocabulary for the tag field.
  $this->vocabulary = entity_create('taxonomy_vocabulary', [
    'name' => 'quickedit testing tags',
    'vid' => 'quickedit_testing_tags',
  ]);
  $this->vocabulary
    ->save();
  $this->fieldName = 'field_' . $this->vocabulary
    ->id();
  $handler_settings = array(
    'target_bundles' => array(
      $this->vocabulary
        ->id() => $this->vocabulary
        ->id(),
    ),
    'auto_create' => TRUE,
  );
  $this
    ->createEntityReferenceField('node', 'article', $this->fieldName, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
  entity_get_form_display('node', 'article', 'default')
    ->setComponent($this->fieldName, [
    'type' => 'entity_reference_autocomplete_tags',
    'weight' => -4,
  ])
    ->save();
  entity_get_display('node', 'article', 'default')
    ->setComponent($this->fieldName, [
    'type' => 'entity_reference_label',
    'weight' => 10,
  ])
    ->save();
  entity_get_display('node', 'article', 'teaser')
    ->setComponent($this->fieldName, [
    'type' => 'entity_reference_label',
    'weight' => 10,
  ])
    ->save();
  $this->term1 = $this
    ->createTerm();
  $this->term2 = $this
    ->createTerm();
  $node = array();
  $node['type'] = 'article';
  $node[$this->fieldName][]['target_id'] = $this->term1
    ->id();
  $node[$this->fieldName][]['target_id'] = $this->term2
    ->id();
  $this->node = $this
    ->drupalCreateNode($node);
  $this->editorUser = $this
    ->drupalCreateUser([
    'access content',
    'create article content',
    'edit any article content',
    'access in-place editing',
  ]);
}