You are here

protected function SearchApiWebTest::checkIndexStatus in Search API 7

Checks whether the index's "Status" tab shows the correct values.

Helper method used by indexItems() and others.

The internal browser will point to the index's "Status" tab after this method is called.

Parameters

int $indexed: (optional) The number of items that should be indexed at the moment. Defaults to 0.

int $total: (optional) The (correct) total number of items. Defaults to 10.

bool $check_buttons: (optional) Whether to check for the correct presence/absence of buttons. Defaults to TRUE.

int|null $on_server: (optional) The number of items actually on the server. Defaults to $indexed.

2 calls to SearchApiWebTest::checkIndexStatus()
SearchApiWebTest::checkIndexingOrder in ./search_api.test
Tests whether items are indexed in the right order.
SearchApiWebTest::indexItems in ./search_api.test
Tests indexing via the UI "Index now" functionality.

File

./search_api.test, line 460
Contains the SearchApiWebTest and the SearchApiUnitTest classes.

Class

SearchApiWebTest
Class for testing Search API functionality via the UI.

Code

protected function checkIndexStatus($indexed = 0, $total = 10, $check_buttons = TRUE, $on_server = NULL) {
  $url = "admin/config/search/search_api/index/{$this->index_id}";
  if (strpos($this->url, $url) === FALSE) {
    $this
      ->drupalGet($url);
  }
  $index_status = t('@indexed/@total indexed', array(
    '@indexed' => $indexed,
    '@total' => $total,
  ));
  $this
    ->assertText($index_status, 'Correct index status displayed.');
  if (!isset($on_server)) {
    $on_server = $indexed;
  }
  $info = format_plural($on_server, 'There is 1 item indexed on the server for this index.', 'There are @count items indexed on the server for this index.');
  $this
    ->assertText(t('Server index status'), 'Server index status displayed.');
  $this
    ->assertText($info, 'Correct server index status displayed.');
  if (!$check_buttons) {
    return;
  }
  $this
    ->assertText(t('enabled'), '"Enabled" status displayed.');
  if ($indexed == $total) {
    $this
      ->assertRaw('disabled="disabled"', '"Index now" form disabled.');
  }
  else {
    $this
      ->assertNoRaw('disabled="disabled"', '"Index now" form enabled.');
  }
}