protected function SearchApiEtTestCase::createIndex in Search API Entity Translation 7.2
Helper function to create a Search API index.
1 call to SearchApiEtTestCase::createIndex()
- 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 227 - Tests for Search API Entity Translation.
Class
- SearchApiEtTestCase
- Tests adding, updating and deleting multilingual Search API items.
Code
protected function createIndex() {
$this->indexId = 'test_index';
$values = array(
'name' => 'Test index',
'machine_name' => $this->indexId,
'item_type' => 'search_api_et_node',
'enabled' => 1,
'description' => 'An index used for testing.',
'server' => $this->serverId,
'options' => array(
'cron_limit' => -1,
'index_directly' => TRUE,
'fields' => array(
'id' => array(
'type' => 'integer',
),
'title' => array(
'type' => 'text',
'boost' => '5.0',
),
'body' => array(
'type' => 'text',
),
'type' => array(
'type' => 'string',
),
'keywords' => array(
'type' => 'list<string>',
),
'search_api_language' => array(
'type' => 'string',
),
),
),
);
$index = entity_create('search_api_index', $values);
$success = (bool) $index
->save();
$this
->assertTrue($success, 'The index was successfully created.');
}