protected function SearchApiDbTest::createIndex in Search API Database Search 7
1 call to SearchApiDbTest::createIndex()
File
- ./
search_api_db.test, line 140
Class
- SearchApiDbTest
- Class for testing index and search capabilities using the Database search module.
Code
protected function createIndex() {
$this->index_id = 'test_index';
$values = array(
'name' => 'Test index',
'machine_name' => $this->index_id,
'item_type' => 'search_api_test',
'enabled' => 1,
'description' => 'An index used for testing.',
'server' => $this->server_id,
'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.');
$status = search_api_index_status($index);
$this
->assertEqual($status['total'], 5, 'Correct item count.');
$this
->assertEqual($status['indexed'], 0, 'All items still need to be indexed.');
}