function TaxonomyImageTest::setUp
Same name in other branches
- 10 core/modules/taxonomy/tests/src/Functional/TaxonomyImageTest.php \Drupal\Tests\taxonomy\Functional\TaxonomyImageTest::setUp()
- 11.x core/modules/taxonomy/tests/src/Functional/TaxonomyImageTest.php \Drupal\Tests\taxonomy\Functional\TaxonomyImageTest::setUp()
Overrides TaxonomyTestBase::setUp
File
-
core/
modules/ taxonomy/ tests/ src/ Functional/ TaxonomyImageTest.php, line 42
Class
- TaxonomyImageTest
- Tests access checks of private image fields.
Namespace
Drupal\Tests\taxonomy\FunctionalCode
protected function setUp() {
parent::setUp();
// Remove access content permission from registered users.
user_role_revoke_permissions(RoleInterface::AUTHENTICATED_ID, [
'access content',
]);
$this->vocabulary = $this->createVocabulary();
// Add a field to the vocabulary.
$entity_type = 'taxonomy_term';
$name = 'field_test';
FieldStorageConfig::create([
'field_name' => $name,
'entity_type' => $entity_type,
'type' => 'image',
'settings' => [
'uri_scheme' => 'private',
],
])->save();
FieldConfig::create([
'field_name' => $name,
'entity_type' => $entity_type,
'bundle' => $this->vocabulary
->id(),
'settings' => [],
])
->save();
/** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */
$display_repository = \Drupal::service('entity_display.repository');
$display_repository->getViewDisplay($entity_type, $this->vocabulary
->id())
->setComponent($name, [
'type' => 'image',
'settings' => [],
])
->save();
$display_repository->getFormDisplay($entity_type, $this->vocabulary
->id())
->setComponent($name, [
'type' => 'image_image',
'settings' => [],
])
->save();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.