KeyValueTestBase.php in MongoDB 8.2
File
modules/mongodb_storage/tests/src/Kernel/KeyValueTestBase.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\mongodb_storage\Kernel;
use Drupal\mongodb\MongoDb;
use Drupal\mongodb_storage\KeyValueFactory;
use Drupal\mongodb_storage\Storage;
use Drupal\Tests\mongodb\Kernel\MongoDbTestBase;
abstract class KeyValueTestBase extends MongoDbTestBase {
const MAGIC = 'mongodb.nonexistent';
protected static $modules = [
MongoDb::MODULE,
Storage::MODULE,
];
public function setUp() : void {
parent::setUp();
$kvpf = $this->container
->get('keyvalue.database');
$kvp = $kvpf
->get(self::MAGIC);
$kvp
->set(self::MAGIC, self::MAGIC);
$kvp
->deleteAll();
$kvef = $this->container
->get('keyvalue.expirable.database');
$kve = $kvef
->get(self::MAGIC);
$kve
->set(self::MAGIC, self::MAGIC);
$kve
->deleteAll();
}
protected function getSettingsArray() : array {
$settings = parent::getSettingsArray();
$settings['databases'][KeyValueFactory::DB_KEYVALUE] = [
static::CLIENT_TEST_ALIAS,
$this
->getDatabasePrefix(),
];
return $settings;
}
}
Classes
Name |
Description |
KeyValueTestBase |
Class KeyValueTestBase provides a base for Key-Value kernel tests. |