You are here

protected function SearchApiDbTest::uninstallModule in Search API Database Search 7

Tests whether removing the configuration again works as it should.

1 call to SearchApiDbTest::uninstallModule()
SearchApiDbTest::testFramework in ./search_api_db.test

File

./search_api_db.test, line 1031

Class

SearchApiDbTest
Class for testing index and search capabilities using the Database search module.

Code

protected function uninstallModule() {

  // See whether clearing the server works.
  // Regression test for #2156151.
  $server = search_api_server_load($this->server_id, TRUE);
  $server
    ->deleteItems();
  $query = $this
    ->buildSearch();
  $results = $query
    ->execute();
  $this
    ->assertEqual($results['result count'], 0, 'Clearing the server worked correctly.');
  $table = 'search_api_db_' . $this->index_id;
  $this
    ->assertTrue(db_table_exists($table), 'The index tables were left in place.');

  // Remove first the index and then the server.
  $index = search_api_index_load($this->index_id, TRUE);
  $index
    ->update(array(
    'server' => NULL,
  ));
  $server = search_api_server_load($this->server_id, TRUE);
  $this
    ->assertEqual($server->options['indexes'], array(), 'The index was successfully removed from the server.');
  $this
    ->assertFalse(db_table_exists($table), 'The index tables were deleted.');
  $server
    ->delete();

  // Uninstall the module.
  module_disable(array(
    'search_api_db',
  ), FALSE);
  $this
    ->assertFalse(module_exists('search_api_db'), 'The Database Search module was successfully disabled.');
  drupal_uninstall_modules(array(
    'search_api_db',
  ), FALSE);
  $prefix = Database::getConnection()
    ->prefixTables('{search_api_db_}') . '%';
  $this
    ->assertEqual(db_find_tables($prefix), array(), 'The Database Search module was successfully uninstalled.');
}