You are here

public function DateRecurOccurrenceTableAttachedTest::testTableCreateDeleteOnFieldStorageCreate in Recurring Dates Field 3.0.x

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

Ensure occurrence table is created and deleted for field storage entities.

File

tests/src/Kernel/DateRecurOccurrenceTableAttachedTest.php, line 53

Class

DateRecurOccurrenceTableAttachedTest
Tests occurrence tables values.

Namespace

Drupal\Tests\date_recur\Kernel

Code

public function testTableCreateDeleteOnFieldStorageCreate() {
  $tableName = 'date_recur__entity_test_rev__abc123';
  $actualExists = $this->container
    ->get('database')
    ->schema()
    ->tableExists($tableName);
  $this
    ->assertFalse($actualExists);
  $fieldStorage = FieldStorageConfig::create([
    'entity_type' => $this->testEntityType,
    'field_name' => 'abc123',
    'type' => 'date_recur',
    'settings' => [
      'datetime_type' => DateRecurItem::DATETIME_TYPE_DATETIME,
    ],
  ]);
  $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);
}