You are here

public function MultiversionIndexFactoryTest::testFactory in Multiversion 8.2

Same name and namespace in other branches
  1. 8 tests/src/Kernel/MultiversionIndexFactoryTest.php \Drupal\Tests\multiversion\Kernel\MultiversionIndexFactoryTest::testFactory()

Tests the factory.

File

tests/src/Kernel/MultiversionIndexFactoryTest.php, line 50

Class

MultiversionIndexFactoryTest
@group multiversion

Namespace

Drupal\Tests\multiversion\Kernel

Code

public function testFactory() {

  // With workspace
  $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);

  // Without a workspace
  $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);

  // Expecting an exception
  $this
    ->setExpectedException(\InvalidArgumentException::class);
  $this->multiversionIndexFactory
    ->get('non.existant.service.name');
}