function EntityReferenceFieldAttributesTest::setUp
Same name in other branches
- 9 core/modules/rdf/tests/src/Functional/EntityReferenceFieldAttributesTest.php \Drupal\Tests\rdf\Functional\EntityReferenceFieldAttributesTest::setUp()
Overrides TaxonomyTestBase::setUp
File
-
core/
modules/ rdf/ tests/ src/ Functional/ EntityReferenceFieldAttributesTest.php, line 52
Class
- EntityReferenceFieldAttributesTest
- Tests RDFa markup generation for taxonomy term fields.
Namespace
Drupal\Tests\rdf\FunctionalCode
protected function setUp() {
parent::setUp();
$web_user = $this->drupalCreateUser([
'bypass node access',
'administer taxonomy',
]);
$this->drupalLogin($web_user);
$this->vocabulary = $this->createVocabulary();
// Create the field.
$this->fieldName = 'field_taxonomy_test';
$handler_settings = [
'target_bundles' => [
$this->vocabulary
->id() => $this->vocabulary
->id(),
],
'auto_create' => TRUE,
];
$this->createEntityReferenceField('node', 'article', $this->fieldName, '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($this->fieldName, [
'type' => 'options_select',
])
->save();
$display_repository->getViewDisplay('node', 'article', 'full')
->setComponent($this->fieldName, [
'type' => 'entity_reference_label',
])
->save();
// Set the RDF mapping for the new field.
rdf_get_mapping('node', 'article')->setFieldMapping($this->fieldName, [
'properties' => [
'dc:subject',
],
'mapping_type' => 'rel',
])
->save();
rdf_get_mapping('taxonomy_term', $this->vocabulary
->id())
->setBundleMapping([
'types' => [
'skos:Concept',
],
])
->setFieldMapping('name', [
'properties' => [
'rdfs:label',
],
])
->save();
// Prepares commonly used URIs.
$this->baseUri = Url::fromRoute('<front>', [], [
'absolute' => TRUE,
])->toString();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.