function TaxonomyTermViewTest::setUp
Same name in other branches
- 9 core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTermViewTest.php \Drupal\Tests\taxonomy\Functional\Views\TaxonomyTermViewTest::setUp()
- 10 core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTermViewTest.php \Drupal\Tests\taxonomy\Functional\Views\TaxonomyTermViewTest::setUp()
- 11.x core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTermViewTest.php \Drupal\Tests\taxonomy\Functional\Views\TaxonomyTermViewTest::setUp()
Overrides TaxonomyTestBase::setUp
File
-
core/
modules/ taxonomy/ tests/ src/ Functional/ Views/ TaxonomyTermViewTest.php, line 48
Class
- TaxonomyTermViewTest
- Tests the taxonomy term view page and its translation.
Namespace
Drupal\Tests\taxonomy\Functional\ViewsCode
protected function setUp($import_test_views = TRUE) {
parent::setUp($import_test_views);
// Create an administrative user.
$this->adminUser = $this->drupalCreateUser([
'administer taxonomy',
'bypass node access',
]);
$this->drupalLogin($this->adminUser);
// Create a vocabulary and add two term reference fields to article nodes.
$this->fieldName1 = mb_strtolower($this->randomMachineName());
$handler_settings = [
'target_bundles' => [
$this->vocabulary
->id() => $this->vocabulary
->id(),
],
'auto_create' => TRUE,
];
$this->createEntityReferenceField('node', 'article', $this->fieldName1, NULL, '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($this->fieldName1, [
'type' => 'options_select',
])
->save();
$display_repository->getViewDisplay('node', 'article')
->setComponent($this->fieldName1, [
'type' => 'entity_reference_label',
])
->save();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.