function ManageFieldsTest::setUp
Same name in this branch
- main core/modules/field_ui/tests/src/FunctionalJavascript/ManageFieldsTest.php \Drupal\Tests\field_ui\FunctionalJavascript\ManageFieldsTest::setUp()
- main core/modules/field_ui/tests/src/Functional/ManageFieldsTest.php \Drupal\Tests\field_ui\Functional\ManageFieldsTest::setUp()
Same name and namespace in other branches
- 11.x core/modules/field_ui/tests/src/FunctionalJavascript/ManageFieldsTest.php \Drupal\Tests\field_ui\FunctionalJavascript\ManageFieldsTest::setUp()
- 11.x core/modules/field_ui/tests/src/Functional/ManageFieldsTest.php \Drupal\Tests\field_ui\Functional\ManageFieldsTest::setUp()
- 10 core/modules/field_ui/tests/src/FunctionalJavascript/ManageFieldsTest.php \Drupal\Tests\field_ui\FunctionalJavascript\ManageFieldsTest::setUp()
- 10 core/modules/field_ui/tests/src/Functional/ManageFieldsTest.php \Drupal\Tests\field_ui\Functional\ManageFieldsTest::setUp()
- 9 core/modules/field_ui/tests/src/Functional/ManageFieldsTest.php \Drupal\Tests\field_ui\Functional\ManageFieldsTest::setUp()
- 8.9.x core/modules/field_ui/tests/src/Functional/ManageFieldsTest.php \Drupal\Tests\field_ui\Functional\ManageFieldsTest::setUp()
- 11.x core/modules/field_ui/tests/src/Kernel/ManageFieldsTest.php \Drupal\Tests\field_ui\Kernel\ManageFieldsTest::setUp()
File
-
core/
modules/ field_ui/ tests/ src/ Kernel/ ManageFieldsTest.php, line 62
Class
- ManageFieldsTest
- Tests the Field UI "Manage fields" screen.
Namespace
Drupal\Tests\field_ui\KernelCode
protected function setUp() : void {
parent::setUp();
$this->installEntitySchema('node');
$this->installEntitySchema('user');
$this->installConfig([
'field_ui',
'user',
]);
// Create a test user.
$admin_user = $this->drupalCreateUser([
'administer node fields',
]);
$this->setCurrentUser($admin_user);
// Create content type, with underscores.
$type_name = $this->randomMachineName(8) . '_test';
$type = $this->drupalCreateContentType([
'name' => $type_name,
'type' => $type_name,
]);
$this->contentType = $type->id();
// Create Basic page and Article node types.
$this->drupalCreateContentType([
'type' => 'page',
'name' => 'Basic page',
]);
$this->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
]);
// Create a vocabulary named "Tags".
$vocabulary = Vocabulary::create([
'name' => 'Tags',
'vid' => 'tags',
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
]);
$vocabulary->save();
$handler_settings = [
'target_bundles' => [
$vocabulary->id() => $vocabulary->id(),
],
];
$this->createEntityReferenceField('node', 'article', 'field_' . $vocabulary->id(), 'Tags', 'taxonomy_term', 'default', $handler_settings);
\Drupal::service('entity_display.repository')->getFormDisplay('node', 'article')
->setComponent('field_' . $vocabulary->id())
->save();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.