DateRecurOccurrenceTableTest.php in Recurring Dates Field 8
File
tests/src/Kernel/DateRecurOccurrenceTableTest.php
View source
<?php
namespace Drupal\Tests\date_recur\Kernel;
use Drupal\date_recur\Plugin\Field\FieldType\DateRecurItem;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\KernelTests\KernelTestBase;
class DateRecurOccurrenceTableTest extends KernelTestBase {
protected function setUp() {
parent::setUp();
$this
->installEntitySchema('entity_test');
}
protected static $modules = [
'entity_test',
'datetime',
'datetime_range',
'date_recur',
'field',
'user',
];
public function testTableCreateDeleteOnFieldStorageCreate() {
$tableName = 'date_recur__entity_test__abc';
$actualExists = $this->container
->get('database')
->schema()
->tableExists($tableName);
$this
->assertFalse($actualExists);
$fieldStorage = FieldStorageConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'abc',
'type' => 'date_recur',
'settings' => [
'datetime_type' => DateRecurItem::DATETIME_TYPE_DATETIME,
'occurrence_handler_plugin' => 'date_recur_occurrence_handler',
],
]);
$fieldStorage
->save();
$actualExists = $this->container
->get('database')
->schema()
->tableExists($tableName);
$this
->assertTrue($actualExists);
$fieldStorage
->delete();
$actualExists = $this->container
->get('database')
->schema()
->tableExists($tableName);
$this
->assertFalse($actualExists);
}
}