function TranslationTest::setUp
Set the default field storage backend for fields created during tests.
Overrides FieldKernelTestBase::setUp
File
-
core/
modules/ field/ tests/ src/ Kernel/ TranslationTest.php, line 74
Class
- TranslationTest
- Tests multilingual fields logic.
Namespace
Drupal\Tests\field\KernelCode
protected function setUp() : void {
parent::setUp();
$this->installEntitySchema('node');
$this->installConfig([
'language',
]);
$this->fieldName = $this->randomMachineName();
$this->entityType = 'entity_test';
$this->fieldStorageDefinition = [
'field_name' => $this->fieldName,
'entity_type' => $this->entityType,
'type' => 'test_field',
'cardinality' => 4,
];
$this->fieldStorage = FieldStorageConfig::create($this->fieldStorageDefinition);
$this->fieldStorage
->save();
$this->fieldDefinition = [
'field_storage' => $this->fieldStorage,
'bundle' => 'entity_test',
];
$this->field = FieldConfig::create($this->fieldDefinition);
$this->field
->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.