public function SearchApiElasticsearchElasticaTest::setUp in Search API Elasticsearch 7
setUp
@access public
Parameters
mixed $config:
Return value
void
File
- modules/
elastica/ tests/ phpunit/ SearchApiElasticsearchElasticaTest.php, line 17 - Contains tests for SearchApiElasticsearchElastica.
Class
- SearchApiElasticsearchElasticaTest
- @file Contains tests for SearchApiElasticsearchElastica.
Code
public function setUp() {
$this->_server = $this
->createServer('elastica_test', 'search_api_elasticsearch_elastica_service', array(
array(
'host' => '127.0.0.1',
'port' => '9200',
),
));
$this->_client = new SearchApiElasticsearchElastica($this->_server);
$this->_index = $this
->createIndex('elastica_test_index', 'node', 'elastica_test');
$this->_index->options['fields'] = array(
'nid' => array(
'type' => 'integer',
),
'title' => array(
'type' => 'text',
),
'friends' => array(
'type' => 'text',
),
);
$this->_items = array(
'1' => array(
'nid' => array(
'value' => 1,
),
'title' => array(
'value' => 'batman',
),
),
'2' => array(
'nid' => array(
'value' => 2,
),
'title' => array(
'value' => 'robin',
),
),
'3' => array(
'nid' => array(
'value' => 3,
),
'title' => array(
'value' => 'catwoman',
),
),
'4' => array(
'nid' => array(
'value' => 4,
),
'title' => array(
'value' => 'joker',
),
'friends' => array(
'value' => array(
'harleyquinn',
'penguin',
),
),
'rivals' => array(
'value' => array(
'batman' => array(
'value' => 'Bruce Wayne',
),
),
),
),
);
$this->_client
->indexItems($this->_index, $this->_items);
$this->_client
->getElasticaIndex($this->_index)
->refresh();
$this->_query = new SearchApiQuery($this->_index);
}