protected function SeparatorsTranslationTest::setUp in Date time day 8
Overrides KernelTestBase::setUp
File
- tests/
src/ Kernel/ SeparatorsTranslationTest.php, line 52
Class
- SeparatorsTranslationTest
- Test to ensure the date_time_day separators are translatable.
Namespace
Drupal\Tests\date_time_day\KernelCode
protected function setUp() {
parent::setUp();
$this
->installEntitySchema('entity_test');
$this
->installEntitySchema('user');
$this
->installConfig([
'system',
]);
$this
->installSchema('system', [
'sequences',
'key_value',
]);
// Add a date_time_day field.
$this->fieldStorage = FieldStorageConfig::create([
'field_name' => mb_strtolower($this
->randomMachineName()),
'entity_type' => 'entity_test',
'type' => 'datetimeday',
'settings' => [
'datetime_type' => DateTimeItem::DATETIME_TYPE_DATE,
'time_type' => DateTimeDayItem::DATEDAY_TIME_DEFAULT_TYPE_FORMAT,
],
]);
$this->fieldStorage
->save();
$this->field = FieldConfig::create([
'field_storage' => $this->fieldStorage,
'bundle' => 'entity_test',
'required' => TRUE,
]);
$this->field
->save();
$display_options = [
'type' => 'datetimeday_default',
'label' => 'hidden',
'settings' => [
'format_type' => 'fallback',
'time_format_type' => 'fallback',
'day_separator' => 'D_UNTRANSLATED',
'time_separator' => 'T_UNTRANSLATED',
],
];
EntityViewDisplay::create([
'targetEntityType' => $this->field
->getTargetEntityTypeId(),
'bundle' => $this->field
->getTargetBundle(),
'mode' => 'default',
'status' => TRUE,
])
->setComponent($this->fieldStorage
->getName(), $display_options)
->save();
}