function TaxonomyTestBase::mockStandardInstall
Same name in this branch
- 11.x core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyTestBase.php \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyTestBase::mockStandardInstall()
Same name in other branches
- 9 core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyTestBase.php \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyTestBase::mockStandardInstall()
- 9 core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTestBase.php \Drupal\Tests\taxonomy\Functional\Views\TaxonomyTestBase::mockStandardInstall()
- 8.9.x core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyTestBase.php \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyTestBase::mockStandardInstall()
- 8.9.x core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTestBase.php \Drupal\Tests\taxonomy\Functional\Views\TaxonomyTestBase::mockStandardInstall()
- 10 core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyTestBase.php \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyTestBase::mockStandardInstall()
- 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 - Sets up the test.
File
-
core/
modules/ taxonomy/ tests/ src/ Functional/ Views/ TaxonomyTestBase.php, line 89
Class
- TaxonomyTestBase
- Base class for all taxonomy tests.
Namespace
Drupal\Tests\taxonomy\Functional\ViewsCode
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();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.