function SearchMultilingualEntityTest::testIndexingThrottle

Tests for indexing throttle with nodes in multiple languages.

File

drupal/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php, line 92
Definition of Drupal\search\Tests\SearchMultilingualEntityTest.

Class

SearchMultilingualEntityTest
Tests entities with multilingual fields.

Namespace

Drupal\search\Tests

Code

function testIndexingThrottle() {

  // Index only 4 items per cron run.
  config('search.settings')
    ->set('index.cron_limit', 4)
    ->save();

  // Update the index. This does the initial processing.
  node_update_index();

  // Run the shutdown function. Testing is a unique case where indexing
  // and searching has to happen in the same request, so running the shutdown
  // function manually is needed to finish the indexing process.
  search_update_totals();

  // Then check how many nodes have been indexed. We have created three nodes,
  // the first has one, the second has two and the third has three language
  // variants. Indexing the third would exceed the throttle limit, so we
  // expect that only the first two will be indexed.
  $status = module_invoke('node', 'search_status');
  $this
    ->assertEqual($status['remaining'], 1, 'Remaining items after updating the search index is 1.');
}