You are here

protected function TaxonomyTestBase::mockStandardInstall in Drupal 8

Same name in this branch
  1. 8 core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTestBase.php \Drupal\Tests\taxonomy\Functional\Views\TaxonomyTestBase::mockStandardInstall()
  2. 8 core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyTestBase.php \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyTestBase::mockStandardInstall()
Same name and namespace in other branches
  1. 9 core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTestBase.php \Drupal\Tests\taxonomy\Functional\Views\TaxonomyTestBase::mockStandardInstall()
  2. 10 core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTestBase.php \Drupal\Tests\taxonomy\Functional\Views\TaxonomyTestBase::mockStandardInstall()

Provides a workaround for the inability to use the standard profile.

See also

https://www.drupal.org/node/1708692

1 call to TaxonomyTestBase::mockStandardInstall()
TaxonomyTestBase::setUp in core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTestBase.php

File

core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTestBase.php, line 82

Class

TaxonomyTestBase
Base class for all taxonomy tests.

Namespace

Drupal\Tests\taxonomy\Functional\Views

Code

protected function mockStandardInstall() {
  $this
    ->drupalCreateContentType([
    'type' => 'article',
  ]);

  // Create the vocabulary for the tag field.
  $this->vocabulary = Vocabulary::create([
    'name' => 'Views testing tags',
    'vid' => 'views_testing_tags',
  ]);
  $this->vocabulary
    ->save();
  $field_name = 'field_' . $this->vocabulary
    ->id();
  $handler_settings = [
    'target_bundles' => [
      $this->vocabulary
        ->id() => $this->vocabulary
        ->id(),
    ],
    'auto_create' => TRUE,
  ];
  $this
    ->createEntityReferenceField('node', 'article', $field_name, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);

  /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */
  $display_repository = \Drupal::service('entity_display.repository');
  $display_repository
    ->getFormDisplay('node', 'article')
    ->setComponent($field_name, [
    'type' => 'entity_reference_autocomplete_tags',
    'weight' => -4,
  ])
    ->save();
  $display_repository
    ->getViewDisplay('node', 'article')
    ->setComponent($field_name, [
    'type' => 'entity_reference_label',
    'weight' => 10,
  ])
    ->save();
  $display_repository
    ->getViewDisplay('node', 'article', 'teaser')
    ->setComponent($field_name, [
    'type' => 'entity_reference_label',
    'weight' => 10,
  ])
    ->save();
}