You are here

protected function SearchApiSolrTest::checkIndexFallback in Search API Solr 4.x

Tests retrieve_data options.

1 call to SearchApiSolrTest::checkIndexFallback()
SearchApiSolrTest::checkBackendSpecificFeatures in tests/src/Kernel/SearchApiSolrTest.php
Checks backend specific features.

File

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

Class

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

Namespace

Drupal\Tests\search_api_solr\Kernel

Code

protected function checkIndexFallback() {
  global $index_fallback_test;

  // If set to TRUE, search_api_solr_test_search_api_solr_documents_alter()
  // turns one out of five test documents into an illegal one.
  $index_fallback_test = TRUE;

  // If five documents are updated as batch, one illegal document causes the
  // entire batch to fail.
  $this
    ->assertEqual($this
    ->indexItems($this->indexId), 0);

  // Enable the fallback to index the documents one by one.
  $server = $this
    ->getIndex()
    ->getServerInstance();
  $config = $server
    ->getBackendConfig();
  $config['index_single_documents_fallback_count'] = 10;
  $server
    ->setBackendConfig($config);
  $server
    ->save();

  // Indexed one by one, four documents get indexed successfully.
  $this
    ->assertEqual($this
    ->indexItems($this->indexId), 4);

  // Don't mess up the remaining document anymore.
  $index_fallback_test = FALSE;

  // Disable the fallback to index the documents one by one.
  $config['index_single_documents_fallback_count'] = 0;
  $server
    ->setBackendConfig($config);
  $server
    ->save();

  // Index the previously broken document that is still in the queue.
  $this
    ->assertEqual($this
    ->indexItems($this->indexId), 1);
}