KeyValueFactoryTest.php in MongoDB 8.2
File
modules/mongodb_storage/tests/src/Kernel/KeyValueFactoryTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\mongodb_storage\Kernel;
use Drupal\mongodb_storage\KeyValueStore;
use Drupal\mongodb_storage\KeyValueStoreExpirable;
use Drupal\mongodb_storage\Storage;
class KeyValueFactoryTest extends KeyValueTestBase {
const COLLECTION = 'xyzzy';
public function testGetExpirable() {
$factory = $this->container
->get(Storage::SERVICE_KVE);
$store = $factory
->get(static::COLLECTION);
$this
->assertInstanceOf(KeyValueStoreExpirable::class, $store, "Store is not an expirable key-value");
$actual = $store
->getCollectionName();
$this
->assertEquals(static::COLLECTION, $actual, 'Collection name matches');
}
public function testGetPersistent() {
$factory = $this->container
->get(Storage::SERVICE_KV);
$store = $factory
->get(static::COLLECTION);
$this
->assertInstanceOf(KeyValueStore::class, $store, "Store is a MongoDB key-value");
$this
->assertNotInstanceOf(KeyValueStoreExpirable::class, $store, "Store is not an expirable key-value");
$actual = $store
->getCollectionName();
$this
->assertEquals(static::COLLECTION, $actual, 'Collection name matches');
}
}