function TranslationWebTest::setUp
Same name in other branches
- 9 core/modules/field/tests/src/Functional/TranslationWebTest.php \Drupal\Tests\field\Functional\TranslationWebTest::setUp()
- 8.9.x core/modules/field/tests/src/Functional/TranslationWebTest.php \Drupal\Tests\field\Functional\TranslationWebTest::setUp()
- 11.x core/modules/field/tests/src/Functional/TranslationWebTest.php \Drupal\Tests\field\Functional\TranslationWebTest::setUp()
Overrides BrowserTestBase::setUp
File
-
core/
modules/ field/ tests/ src/ Functional/ TranslationWebTest.php, line 59
Class
- TranslationWebTest
- Tests multilingual fields logic that require a full environment.
Namespace
Drupal\Tests\field\FunctionalCode
protected function setUp() : void {
parent::setUp();
$this->fieldName = $this->randomMachineName() . '_field_name';
$field_storage = [
'field_name' => $this->fieldName,
'entity_type' => $this->entityTypeId,
'type' => 'test_field',
'cardinality' => 4,
];
FieldStorageConfig::create($field_storage)->save();
$this->fieldStorage = FieldStorageConfig::load($this->entityTypeId . '.' . $this->fieldName);
$field = [
'field_storage' => $this->fieldStorage,
'bundle' => $this->entityTypeId,
];
FieldConfig::create($field)->save();
$this->field = FieldConfig::load($this->entityTypeId . '.' . $field['bundle'] . '.' . $this->fieldName);
\Drupal::service('entity_display.repository')->getFormDisplay($this->entityTypeId, $this->entityTypeId)
->setComponent($this->fieldName)
->save();
for ($i = 0; $i < 3; ++$i) {
ConfigurableLanguage::create([
'id' => 'l' . $i,
'label' => $this->randomString(),
])
->save();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.