You are here

public function KeyValueTestBase::setUp in MongoDB 8.2

Overrides MongoDbTestBase::setUp

1 call to KeyValueTestBase::setUp()
SqlImportTest::setUp in modules/mongodb_storage/tests/src/Kernel/SqlImportTest.php
Install the database keyvalue tables for import.
1 method overrides KeyValueTestBase::setUp()
SqlImportTest::setUp in modules/mongodb_storage/tests/src/Kernel/SqlImportTest.php
Install the database keyvalue tables for import.

File

modules/mongodb_storage/tests/src/Kernel/KeyValueTestBase.php, line 35

Class

KeyValueTestBase
Class KeyValueTestBase provides a base for Key-Value kernel tests.

Namespace

Drupal\Tests\mongodb_storage\Kernel

Code

public function setUp() : void {
  parent::setUp();

  // Force creation of KV tables after https://www.drupal.org/node/3143286

  /** @var \Drupal\Core\KeyValueStore\KeyValueFactoryInterface $kvpf */
  $kvpf = $this->container
    ->get('keyvalue.database');
  $kvp = $kvpf
    ->get(self::MAGIC);
  $kvp
    ->set(self::MAGIC, self::MAGIC);
  $kvp
    ->deleteAll();

  /** @var \Drupal\Core\KeyValueStore\KeyValueExpirableFactoryInterface $kvef */
  $kvef = $this->container
    ->get('keyvalue.expirable.database');
  $kve = $kvef
    ->get(self::MAGIC);
  $kve
    ->set(self::MAGIC, self::MAGIC);
  $kve
    ->deleteAll();
}