You are here

protected function DateTimezoneTest::setUp in Double Field 4.x

Same name and namespace in other branches
  1. 8.3 tests/src/Functional/DateTimezoneTest.php \Drupal\Tests\double_field\Functional\DateTimezoneTest::setUp()

Overrides TestBase::setUp

File

tests/src/Functional/DateTimezoneTest.php, line 18

Class

DateTimezoneTest
A test for date timezone calculations.

Namespace

Drupal\Tests\double_field\Functional

Code

protected function setUp() : void {
  parent::setUp();
  $storage_settings['storage']['first']['type'] = 'datetime_iso8601';
  $storage_settings['storage']['first']['datetime_type'] = 'datetime';
  $storage_settings['storage']['second']['type'] = 'datetime_iso8601';
  $storage_settings['storage']['second']['datetime_type'] = 'date';
  $this
    ->saveFieldStorageSettings($storage_settings);

  /** @var \Drupal\Core\Entity\Entity\EntityViewDisplay $view_display */
  $view_display = \Drupal::entityTypeManager()
    ->getStorage('entity_view_display')
    ->load("node.{$this->contentTypeId}.default");
  $settings['first']['format_type'] = 'html_datetime';
  $settings['second']['format_type'] = 'html_datetime';
  $options = [
    'label' => 'hidden',
    'type' => 'double_field_unformatted_list',
    'settings' => NestedArray::mergeDeep(BaseFormatter::defaultSettings(), $settings),
    'third_party_settings' => [],
  ];
  $view_display
    ->setComponent($this->fieldName, $options);
  $view_display
    ->save();
}