public function EntityTestDateRangeTest::setUp in Drupal 8
Same name and namespace in other branches
- 9 core/modules/datetime_range/tests/src/Functional/EntityResource/EntityTest/EntityTestDateRangeTest.php \Drupal\Tests\datetime_range\Functional\EntityResource\EntityTest\EntityTestDateRangeTest::setUp()
Overrides EntityResourceTestBase::setUp
File
- core/
modules/ datetime_range/ tests/ src/ Functional/ EntityResource/ EntityTest/ EntityTestDateRangeTest.php, line 50
Class
- EntityTestDateRangeTest
- Tests the 'daterange' field's normalization.
Namespace
Drupal\Tests\datetime_range\Functional\EntityResource\EntityTestCode
public function setUp() {
parent::setUp();
// Add datetime_range field.
FieldStorageConfig::create([
'field_name' => static::$fieldName,
'type' => 'daterange',
'entity_type' => static::$entityTypeId,
'settings' => [
'datetime_type' => DateRangeItem::DATETIME_TYPE_ALLDAY,
],
])
->save();
FieldConfig::create([
'field_name' => static::$fieldName,
'entity_type' => static::$entityTypeId,
'bundle' => $this->entity
->bundle(),
])
->save();
// Reload entity so that it has the new field.
$this->entity = $this->entityStorage
->load($this->entity
->id());
$this->entity
->set(static::$fieldName, [
'value' => static::$dateString,
'end_value' => static::$dateString,
]);
$this->entity
->save();
}