You are here

public function DependencyRemovalTest::testIndexDependency in Search API Autocomplete 8

Tests that the dependency on the index works correctly.

File

tests/src/Kernel/DependencyRemovalTest.php, line 99

Class

DependencyRemovalTest
Tests dependency handling of the search entity.

Namespace

Drupal\Tests\search_api_autocomplete\Kernel

Code

public function testIndexDependency() {
  $this->search
    ->save();
  $index = $this->search
    ->getIndex();

  // Verify that the dependency is included.
  $dependencies = $this->search
    ->getDependencies();
  $this
    ->assertArrayHasKey('config', $dependencies);
  $this
    ->assertContains($index
    ->getConfigDependencyName(), $dependencies['config']);

  // Verify that deleting the index will also delete the search.
  $index
    ->delete();
  $search = Search::load($this->search
    ->id());
  $this
    ->assertNull($search);
}