1<?php
2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
3//
4// All Rights Reserved. See copyright.txt for details and a complete list of authors.
5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6// $Id$
7
8class Search_Elastic_SortTest extends Search_Index_SortTest
9{
10	private $unified_stopwords;
11
12	function setUp()
13	{
14		global $prefs;
15		$this->unified_stopwords = $prefs['unified_stopwords'];
16		$prefs['unified_stopwords'] = '';
17
18		static $count = 0;
19
20		$elasticSearchHost = empty(getenv('ELASTICSEARCH_HOST')) ? 'localhost' : getenv('ELASTICSEARCH_HOST');
21		$connection = new Search_Elastic_Connection('http://' . $elasticSearchHost . ':9200');
22
23		$status = $connection->getStatus();
24		if (! $status->ok) {
25			$this->markTestSkipped('Elasticsearch needs to be available on ' . $elasticSearchHost . ':9200 for the test to run.');
26		}
27
28		$this->index = new Search_Elastic_Index($connection, 'test_index');
29		$this->index->destroy();
30
31		$this->populate($this->index);
32	}
33
34	function tearDown()
35	{
36		global $prefs;
37		$prefs['unified_stopwords'] = $this->unified_stopwords;
38
39		if ($this->index) {
40			$this->index->destroy();
41		}
42	}
43}
44