You are here

protected function SearchApiWebTest::deleteServer in Search API 7

Tests whether deleting the server works correctly.

The index still lying on the server should be disabled and removed from it. Also, any tasks with that server's ID should be deleted.

1 call to SearchApiWebTest::deleteServer()
SearchApiWebTest::testFramework in ./search_api.test
Tests correct admin UI, indexing and search behavior.

File

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

Class

SearchApiWebTest
Class for testing Search API functionality via the UI.

Code

protected function deleteServer() {

  // Insert some dummy tasks to check for.
  $server = $this
    ->server();
  search_api_server_tasks_add($server, 'foo');
  search_api_server_tasks_add($server, 'bar', $this
    ->index());
  $task_count = db_query('SELECT COUNT(id) FROM {search_api_task}')
    ->fetchField();
  $this
    ->assertEqual($task_count, 2, 'Dummy tasks were added.');

  // Delete the server.
  $this
    ->drupalPost("admin/config/search/search_api/server/{$this->server_id}/delete", array(), t('Confirm'));
  $this
    ->assertNoText('test-name-foo', 'Server no longer listed.');
  $this
    ->drupalGet("admin/config/search/search_api/index/{$this->index_id}");
  $this
    ->assertNoText(t('Server'), 'The index was removed from the server.');
  $this
    ->assertText(t('disabled'), 'The index was disabled.');

  // Check whether the tasks were correctly deleted.
  $task_count = db_query('SELECT COUNT(id) FROM {search_api_task}')
    ->fetchField();
  $this
    ->assertEqual($task_count, 0, 'Remaining server tasks were correctly deleted.');
}