You are here

protected function SearchApiSolrTest::detectSolrAvailability in Search API Solr 8

Detects the availability of a Solr Server and sets $this->solrAvailable.

1 call to SearchApiSolrTest::detectSolrAvailability()
SearchApiSolrTest::setUp in tests/src/Kernel/SearchApiSolrTest.php

File

tests/src/Kernel/SearchApiSolrTest.php, line 90

Class

SearchApiSolrTest
Tests index and search capabilities using the Solr search backend.

Namespace

Drupal\Tests\search_api_solr\Kernel

Code

protected function detectSolrAvailability() {

  // Because this is a kernel test, the routing isn't built by default, so
  // we have to force it.
  \Drupal::service('router.builder')
    ->rebuild();
  try {
    $backend = Server::load($this->serverId)
      ->getBackend();
    if ($backend
      ->isAvailable()) {
      $this->solrAvailable = TRUE;
    }
  } catch (\Exception $e) {
  }
}