function SeparatorTranslationTest::setUp
Same name in other branches
- 8.9.x core/modules/datetime_range/tests/src/Kernel/SeparatorTranslationTest.php \Drupal\Tests\datetime_range\Kernel\SeparatorTranslationTest::setUp()
- 10 core/modules/datetime_range/tests/src/Kernel/SeparatorTranslationTest.php \Drupal\Tests\datetime_range\Kernel\SeparatorTranslationTest::setUp()
- 11.x core/modules/datetime_range/tests/src/Kernel/SeparatorTranslationTest.php \Drupal\Tests\datetime_range\Kernel\SeparatorTranslationTest::setUp()
Overrides KernelTestBase::setUp
File
-
core/
modules/ datetime_range/ tests/ src/ Kernel/ SeparatorTranslationTest.php, line 51
Class
- SeparatorTranslationTest
- Test to ensure the datetime range separator is translatable.
Namespace
Drupal\Tests\datetime_range\KernelCode
protected function setUp() : void {
parent::setUp();
$this->installEntitySchema('entity_test');
$this->installEntitySchema('user');
$this->installConfig([
'system',
]);
$this->installSchema('system', [
'sequences',
]);
// Add a datetime range field.
$this->fieldStorage = FieldStorageConfig::create([
'field_name' => mb_strtolower($this->randomMachineName()),
'entity_type' => 'entity_test',
'type' => 'daterange',
'settings' => [
'datetime_type' => DateTimeItem::DATETIME_TYPE_DATE,
],
]);
$this->fieldStorage
->save();
$this->field = FieldConfig::create([
'field_storage' => $this->fieldStorage,
'bundle' => 'entity_test',
'required' => TRUE,
]);
$this->field
->save();
$display_options = [
'type' => 'daterange_default',
'label' => 'hidden',
'settings' => [
'format_type' => 'fallback',
'separator' => 'UNTRANSLATED',
],
];
EntityViewDisplay::create([
'targetEntityType' => $this->field
->getTargetEntityTypeId(),
'bundle' => $this->field
->getTargetBundle(),
'mode' => 'default',
'status' => TRUE,
])
->setComponent($this->fieldStorage
->getName(), $display_options)
->save();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.