protected function SearchApiEtTestCase::createServer in Search API Entity Translation 7.2
Helper function to create a Search API server.
1 call to SearchApiEtTestCase::createServer()
- SearchApiEtTestCase::setUp in tests/
search_api_et.test - Sets up a Drupal site for running functional and integration tests.
File
- tests/
search_api_et.test, line 196 - Tests for Search API Entity Translation.
Class
- SearchApiEtTestCase
- Tests adding, updating and deleting multilingual Search API items.
Code
protected function createServer() {
$this->serverId = '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->serverId,
'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.');
}