MultiversionIndexFactoryTest.php in Multiversion 8.2
File
tests/src/Kernel/MultiversionIndexFactoryTest.php
View source
<?php
namespace Drupal\Tests\multiversion\Kernel;
use Drupal\KernelTests\KernelTestBase;
use Drupal\multiversion\Entity\Index\EntityIndexInterface;
use Drupal\multiversion\Entity\Index\RevisionIndexInterface;
use Drupal\multiversion\Entity\Index\RevisionTreeIndexInterface;
use Drupal\multiversion\Entity\Index\SequenceIndexInterface;
use Drupal\multiversion\Entity\Index\UuidIndexInterface;
use Drupal\workspaces\Entity\Workspace;
class MultiversionIndexFactoryTest extends KernelTestBase {
public static $modules = [
'multiversion',
'workspaces',
'key_value',
'serialization',
'user',
'system',
];
protected $multiversionIndexFactory;
protected $workspace;
protected function setUp() {
parent::setUp();
$this
->installEntitySchema('workspace');
$this
->installConfig('multiversion');
$this->multiversionIndexFactory = \Drupal::service('multiversion.entity_index.factory');
$this->workspace = Workspace::create([
'id' => 'le_workspace',
'label' => 'Le Workspace',
]);
$this->workspace
->save();
}
public function testFactory() {
$sequence_index = $this->multiversionIndexFactory
->get('multiversion.entity_index.sequence', $this->workspace);
$this
->assertTrue($sequence_index instanceof SequenceIndexInterface);
$id_index = $this->multiversionIndexFactory
->get('multiversion.entity_index.id', $this->workspace);
$this
->assertTrue($id_index instanceof EntityIndexInterface);
$uuid_index = $this->multiversionIndexFactory
->get('multiversion.entity_index.uuid', $this->workspace);
$this
->assertTrue($uuid_index instanceof UuidIndexInterface);
$rev_index = $this->multiversionIndexFactory
->get('multiversion.entity_index.rev', $this->workspace);
$this
->assertTrue($rev_index instanceof RevisionIndexInterface);
$rev_tree_index = $this->multiversionIndexFactory
->get('multiversion.entity_index.rev.tree', $this->workspace);
$this
->assertTrue($rev_tree_index instanceof RevisionTreeIndexInterface);
$sequence_index = $this->multiversionIndexFactory
->get('multiversion.entity_index.sequence');
$this
->assertTrue($sequence_index instanceof SequenceIndexInterface);
$id_index = $this->multiversionIndexFactory
->get('multiversion.entity_index.id');
$this
->assertTrue($id_index instanceof EntityIndexInterface);
$uuid_index = $this->multiversionIndexFactory
->get('multiversion.entity_index.uuid');
$this
->assertTrue($uuid_index instanceof UuidIndexInterface);
$rev_index = $this->multiversionIndexFactory
->get('multiversion.entity_index.rev');
$this
->assertTrue($rev_index instanceof RevisionIndexInterface);
$rev_tree_index = $this->multiversionIndexFactory
->get('multiversion.entity_index.rev.tree');
$this
->assertTrue($rev_tree_index instanceof RevisionTreeIndexInterface);
$this
->setExpectedException(\InvalidArgumentException::class);
$this->multiversionIndexFactory
->get('non.existant.service.name');
}
}