You are here

protected function StoreDateTimeTest::setUp in Commerce Core 8.2

Overrides CommerceBrowserTestBase::setUp

File

modules/store/tests/src/Functional/StoreDateTimeTest.php, line 42

Class

StoreDateTimeTest
Tests the commerce_store_datetime formatter and widget.

Namespace

Drupal\Tests\commerce_store\Functional

Code

protected function setUp() : void {
  parent::setUp();
  $field_storage = FieldStorageConfig::create([
    'field_name' => 'test_date',
    'entity_type' => 'entity_test',
    'type' => 'datetime',
    'settings' => [
      'datetime_type' => 'datetime',
    ],
  ]);
  $field_storage
    ->save();
  $field = FieldConfig::create([
    'field_name' => 'test_date',
    'entity_type' => 'entity_test',
    'bundle' => 'entity_test',
    'label' => 'Test date!',
  ]);
  $field
    ->save();
  $form_display = commerce_get_entity_display('entity_test', 'entity_test', 'form');
  $form_display
    ->setComponent('test_date', [
    'type' => 'commerce_store_datetime',
  ])
    ->save();
  $view_display = commerce_get_entity_display('entity_test', 'entity_test', 'view');
  $view_display
    ->setComponent('test_date', [
    'type' => 'commerce_store_datetime',
  ])
    ->save();
}