You are here

protected function TaxonomyEntityIndexEntityTest::assertThatEntityInsertWritesToTheIndex in Taxonomy Entity Index 8

Test that entity creation writes to the index.

Parameters

\Drupal\taxonomy\TermInterface[] $terms: Terms to reference.

Return value

\Drupal\entity_test\Entity\EntityTest Test entity.

1 call to TaxonomyEntityIndexEntityTest::assertThatEntityInsertWritesToTheIndex()
TaxonomyEntityIndexEntityTest::testWritingToIndexTable in tests/src/Kernel/TaxonomyEntityIndexEntityTest.php
Tests operations that insert/update/delete to the index table.

File

tests/src/Kernel/TaxonomyEntityIndexEntityTest.php, line 111

Class

TaxonomyEntityIndexEntityTest
Defines a class for testing basic functionality of taxonomy_entity_index.

Namespace

Drupal\Tests\taxonomy_entity_index\Kernel

Code

protected function assertThatEntityInsertWritesToTheIndex(array $terms) {
  $entity = EntityTest::create([
    'type' => 'termz',
    'termz' => $terms,
  ]);
  $entity
    ->save();
  $this
    ->assertCount(count($terms), $this->database
    ->select('taxonomy_entity_index', 'tei')
    ->fields('tei')
    ->condition('entity_id', $entity
    ->id())
    ->condition('entity_type', $entity
    ->getEntityTypeId())
    ->execute()
    ->fetchAll());
  return $entity;
}