You are here

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

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

File

./search_api_db.test, line 112

Class

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

Code

protected function createServer() {
  $this->server_id = 'database_search_server';
  global $databases;
  $database = 'default:default';

  // Make sure to pick an available connection and to not rely on any
  // defaults.
  foreach ($databases as $key => $targets) {
    foreach ($targets as $target => $info) {
      $database = "{$key}:{$target}";
      break;
    }
  }
  $values = array(
    'name' => 'Database search server',
    'machine_name' => $this->server_id,
    'enabled' => 1,
    'description' => 'A server used for testing.',
    'class' => 'search_api_db_service',
    'options' => array(
      'min_chars' => 3,
      'database' => $database,
      'partial_matches' => FALSE,
    ),
  );
  $success = (bool) entity_create('search_api_server', $values)
    ->save();
  $this
    ->assertTrue($success, 'The server was successfully created.');
}