You are here

protected function DateRecurViewsOccurrenceFilterAttachedTest::setUp in Recurring Dates Field 3.x

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/DateRecurViewsOccurrenceFilterAttachedTest.php \Drupal\Tests\date_recur\Kernel\DateRecurViewsOccurrenceFilterAttachedTest::setUp()
  2. 3.0.x tests/src/Kernel/DateRecurViewsOccurrenceFilterAttachedTest.php \Drupal\Tests\date_recur\Kernel\DateRecurViewsOccurrenceFilterAttachedTest::setUp()
  3. 3.1.x tests/src/Kernel/DateRecurViewsOccurrenceFilterAttachedTest.php \Drupal\Tests\date_recur\Kernel\DateRecurViewsOccurrenceFilterAttachedTest::setUp()

Parameters

bool $import_test_views: Should the views specified on the test class be imported. If you need to setup some additional stuff, like fields, you need to call false and then call createTestViews for your own.

Overrides DateRecurViewsOccurrenceFilterTest::setUp

File

tests/src/Kernel/DateRecurViewsOccurrenceFilterAttachedTest.php, line 28

Class

DateRecurViewsOccurrenceFilterAttachedTest
Tests the results of 'date_recur_occurrences_filter' filter plugin.

Namespace

Drupal\Tests\date_recur\Kernel

Code

protected function setUp($import_test_views = TRUE) {
  parent::setUp(FALSE);

  // This is the name of the attached field.
  $this->fieldName = 'dr_attached';
  $fieldStorage = FieldStorageConfig::create([
    'entity_type' => 'dr_entity_test',
    'field_name' => $this->fieldName,
    'type' => 'date_recur',
    'settings' => [
      'datetime_type' => DateRecurItem::DATETIME_TYPE_DATETIME,
    ],
  ]);
  $fieldStorage
    ->save();
  $field = [
    'field_name' => $this->fieldName,
    'entity_type' => 'dr_entity_test',
    'bundle' => 'dr_entity_test',
  ];
  FieldConfig::create($field)
    ->save();
  \Drupal::service('entity_field.manager')
    ->clearCachedFieldDefinitions();
  \Drupal::service('entity_type.manager')
    ->clearCachedDefinitions();
}