public function DateRecurSubFieldTest::testOccurrenceTable in Recurring Dates Field 8.2
Same name and namespace in other branches
- 3.x tests/src/Kernel/DateRecurSubFieldTest.php \Drupal\Tests\date_recur\Kernel\DateRecurSubFieldTest::testOccurrenceTable()
- 3.0.x tests/src/Kernel/DateRecurSubFieldTest.php \Drupal\Tests\date_recur\Kernel\DateRecurSubFieldTest::testOccurrenceTable()
- 3.1.x tests/src/Kernel/DateRecurSubFieldTest.php \Drupal\Tests\date_recur\Kernel\DateRecurSubFieldTest::testOccurrenceTable()
Tests occurrence table is created for subclassed fields.
File
- tests/
src/ Kernel/ DateRecurSubFieldTest.php, line 43
Class
- DateRecurSubFieldTest
- Tests fields subclassing date_recur.
Namespace
Drupal\Tests\date_recur\KernelCode
public function testOccurrenceTable() {
$fieldStorage = FieldStorageConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'abc',
'type' => 'date_recur_sub',
'settings' => [
'datetime_type' => DateRecurSubItem::DATETIME_TYPE_DATETIME,
],
]);
$fieldStorage
->save();
$fieldConfig = FieldConfig::create([
'field_name' => 'abc',
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
]);
$fieldConfig
->save();
$entity = EntityTest::create();
$entity->abc = [
'value' => '2014-06-15T23:00:00',
'end_value' => '2014-06-16T07:00:00',
'rrule' => 'FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR',
'infinite' => '1',
'timezone' => 'Australia/Sydney',
];
$entity
->save();
$tableName = DateRecurOccurrences::getOccurrenceCacheStorageTableName($fieldStorage);
$actualExists = $this->container
->get('database')
->schema()
->tableExists($tableName);
$this
->assertTrue($actualExists);
// Test deletion.
$fieldStorage
->delete();
$actualExists = $this->container
->get('database')
->schema()
->tableExists($tableName);
$this
->assertFalse($actualExists);
}