You are here

protected function TaxonomyEntityIndexEntityTest::assertThatEntityDeletionUpdatesTheIndex in Taxonomy Entity Index 8

Test that deleting an entity updates the index.

Parameters

\Drupal\entity_test\Entity\EntityTest $entity: Entity to update.

1 call to TaxonomyEntityIndexEntityTest::assertThatEntityDeletionUpdatesTheIndex()
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 208

Class

TaxonomyEntityIndexEntityTest
Defines a class for testing basic functionality of taxonomy_entity_index.

Namespace

Drupal\Tests\taxonomy_entity_index\Kernel

Code

protected function assertThatEntityDeletionUpdatesTheIndex(EntityTest $entity) {
  $entity
    ->delete();
  $this
    ->assertCount(0, $this->database
    ->select('taxonomy_entity_index', 'tei')
    ->fields('tei')
    ->condition('entity_id', $entity
    ->id())
    ->condition('entity_type', $entity
    ->getEntityTypeId())
    ->execute()
    ->fetchAll());

  // Should not remove other entries though (second entity created earlier).
  $this
    ->assertGreaterThan(0, $this->database
    ->select('taxonomy_entity_index', 'tei')
    ->fields('tei')
    ->condition('entity_id', $entity
    ->id(), '<>')
    ->condition('entity_type', $entity
    ->getEntityTypeId())
    ->execute()
    ->fetchAll());
}