mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Remove sphinx search engine tests
This commit is contained in:
@@ -25,11 +25,6 @@ before_script:
|
|||||||
- echo 'extension="memcached.so"' > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/memcached.ini
|
- echo 'extension="memcached.so"' > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/memcached.ini
|
||||||
- echo "extension=zmq.so" > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/zmq.ini
|
- echo "extension=zmq.so" > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/zmq.ini
|
||||||
- yes | pecl install imagick
|
- yes | pecl install imagick
|
||||||
- wget http://sphinxsearch.com/files/sphinx-2.0.6-release.tar.gz
|
|
||||||
- tar xzf sphinx-2.0.6-release.tar.gz
|
|
||||||
- sh -c "cd sphinx-2.0.6-release && wget http://snowball.tartarus.org/dist/libstemmer_c.tgz && tar xzf libstemmer_c.tgz && ./configure --with-libstemmer --with-iconv --with-mysql --enable-id64 --quiet && make -j --quiet && sudo make install"
|
|
||||||
- sudo mkdir -p /var/sphinx/datas
|
|
||||||
- sudo chmod -R 0777 /var/sphinx
|
|
||||||
- mysql -e 'create database update39_test;create database ab_test;create database db_test; create database ab_unitTests; create database db_unitTests;'
|
- mysql -e 'create database update39_test;create database ab_test;create database db_test; create database ab_unitTests; create database db_unitTests;'
|
||||||
- sudo mysql -e "GRANT ALL PRIVILEGES ON ab_unitTests.* TO 'phraseaUnitTests'@'localhost' IDENTIFIED BY 'iWvGxPE8' WITH GRANT OPTION"
|
- sudo mysql -e "GRANT ALL PRIVILEGES ON ab_unitTests.* TO 'phraseaUnitTests'@'localhost' IDENTIFIED BY 'iWvGxPE8' WITH GRANT OPTION"
|
||||||
- sudo mysql -e "GRANT ALL PRIVILEGES ON db_unitTests.* TO 'phraseaUnitTests'@'localhost' IDENTIFIED BY 'iWvGxPE8' WITH GRANT OPTION"
|
- sudo mysql -e "GRANT ALL PRIVILEGES ON db_unitTests.* TO 'phraseaUnitTests'@'localhost' IDENTIFIED BY 'iWvGxPE8' WITH GRANT OPTION"
|
||||||
|
@@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Alchemy\Tests\Phrasea\SearchEngine;
|
|
||||||
|
|
||||||
use Alchemy\Phrasea\SearchEngine\SphinxSearch\SphinxSearchEngine;
|
|
||||||
use Alchemy\Phrasea\SearchEngine\SphinxSearch\ConfigurationPanel;
|
|
||||||
|
|
||||||
class SphinxSearchConfigurationPanelTest extends ConfigurationPanelAbstractTest
|
|
||||||
{
|
|
||||||
public function getPanel()
|
|
||||||
{
|
|
||||||
return new ConfigurationPanel(new SphinxSearchEngine(self::$DI['app'], 'localhost', 9306, 'localhost', 9308), self::$DI['app']['conf']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetAVailableCharsets()
|
|
||||||
{
|
|
||||||
$charsets = $this->getPanel()->getAvailableCharsets();
|
|
||||||
|
|
||||||
$this->assertInternalType('array', $charsets);
|
|
||||||
foreach ($charsets as $name => $charset) {
|
|
||||||
$this->assertInternalType('string', $name);
|
|
||||||
$this->assertInstanceOf('Alchemy\Phrasea\SearchEngine\SphinxSearch\AbstractCharset', $charset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGenerateSphinxConf()
|
|
||||||
{
|
|
||||||
$databoxes = self::$DI['app']['phraseanet.appbox']->get_databoxes();
|
|
||||||
$configuration = $this->getPanel()->getConfiguration();
|
|
||||||
|
|
||||||
$conf = $this->getPanel()->generateSphinxConf($databoxes, $configuration);
|
|
||||||
$this->assertInternalType('string', $conf);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,166 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Alchemy\Tests\Phrasea\SearchEngine;
|
|
||||||
|
|
||||||
use Alchemy\Phrasea\SearchEngine\SphinxSearch\SphinxSearchEngine;
|
|
||||||
use Symfony\Component\Process\ExecutableFinder;
|
|
||||||
use Symfony\Component\Process\Process;
|
|
||||||
|
|
||||||
class SphinxSearchEngineTest extends SearchEngineAbstractTest
|
|
||||||
{
|
|
||||||
private static $skipped = false;
|
|
||||||
private static $config;
|
|
||||||
private static $searchd;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\SearchEngine\SphinxSearch\SphinxSearchEngine
|
|
||||||
*/
|
|
||||||
public function bootTestCase()
|
|
||||||
{
|
|
||||||
$binaryFinder = new ExecutableFinder();
|
|
||||||
$indexer = $binaryFinder->find('indexer');
|
|
||||||
|
|
||||||
$searchd = $binaryFinder->find('searchd');
|
|
||||||
|
|
||||||
if (!$indexer || !$searchd) {
|
|
||||||
self::$skipped = true;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$app = self::$DI['app'];
|
|
||||||
$appbox = $app['phraseanet.appbox'];
|
|
||||||
|
|
||||||
$app['conf']->set(['main', 'search-engine', 'options'], [
|
|
||||||
'host' => '127.0.0.1',
|
|
||||||
'port' => 9312,
|
|
||||||
'rt_host' => '127.0.0.1',
|
|
||||||
'rt_port' => 9306,
|
|
||||||
]);
|
|
||||||
|
|
||||||
self::$searchEngine = SphinxSearchEngine::create($app, $app['conf']->get(['main', 'search-engine', 'options']));
|
|
||||||
|
|
||||||
self::$config = tempnam(sys_get_temp_dir(), 'tmp_sphinx.conf');
|
|
||||||
$configuration = self::$searchEngine->getConfigurationPanel()->getConfiguration();
|
|
||||||
$configuration['date_fields'] = [];
|
|
||||||
|
|
||||||
foreach ($appbox->get_databoxes() as $databox) {
|
|
||||||
foreach ($databox->get_meta_structure() as $databox_field) {
|
|
||||||
if ($databox_field->get_type() != \databox_field::TYPE_DATE) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$configuration['date_fields'][] = $databox_field->get_name();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$configuration['date_fields'] = array_unique($configuration['date_fields']);
|
|
||||||
|
|
||||||
self::$searchEngine->getConfigurationPanel()->saveConfiguration($configuration);
|
|
||||||
|
|
||||||
$configFile = self::$searchEngine->getConfigurationPanel()->generateSphinxConf($appbox->get_databoxes(), $configuration);
|
|
||||||
|
|
||||||
file_put_contents(self::$config, $configFile);
|
|
||||||
|
|
||||||
$process = new Process($indexer . ' --all -c ' . self::$config);
|
|
||||||
$process->run();
|
|
||||||
|
|
||||||
self::$searchd = new Process($searchd . ' -c ' . self::$config);
|
|
||||||
self::$searchd->run();
|
|
||||||
|
|
||||||
self::$searchEngine = SphinxSearchEngine::create($app, $app['conf']->get(['main', 'search-engine', 'options']));
|
|
||||||
self::$searchEngineClass = 'Alchemy\Phrasea\SearchEngine\SphinxSearch\SphinxSearchEngine';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setUp()
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
if (self::$skipped) {
|
|
||||||
$this->markTestSkipped('SphinxSearch is not present on system');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function tearDown()
|
|
||||||
{
|
|
||||||
if (!self::$skipped) {
|
|
||||||
self::$searchEngine->removeRecord(self::$DI['record_2']);
|
|
||||||
}
|
|
||||||
|
|
||||||
parent::tearDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function initialize()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function tearDownAfterClass()
|
|
||||||
{
|
|
||||||
if (!self::$skipped) {
|
|
||||||
$binaryFinder = new ExecutableFinder();
|
|
||||||
$searchd = $binaryFinder->find('searchd');
|
|
||||||
|
|
||||||
self::$searchd = new Process($searchd . ' --stop -c ' . self::$config);
|
|
||||||
self::$searchd->run();
|
|
||||||
|
|
||||||
unlink(self::$config);
|
|
||||||
}
|
|
||||||
|
|
||||||
self::$skipped = self::$config = self::$searchd = null;
|
|
||||||
parent::tearDownAfterClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\SearchEngine\SphinxSearch\SphinxSearchEngine::autocomplete
|
|
||||||
*/
|
|
||||||
public function testAutocomplete()
|
|
||||||
{
|
|
||||||
$record = self::$DI['record_2'];
|
|
||||||
|
|
||||||
$toupdate = [];
|
|
||||||
|
|
||||||
foreach ($record->get_databox()->get_meta_structure()->get_elements() as $field) {
|
|
||||||
try {
|
|
||||||
$values = $record->get_caption()->get_field($field->get_name())->get_values();
|
|
||||||
$value = array_pop($values);
|
|
||||||
$meta_id = $value->getId();
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$meta_id = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$toupdate[$field->get_id()] = [
|
|
||||||
'meta_id' => $meta_id
|
|
||||||
, 'meta_struct_id' => $field->get_id()
|
|
||||||
, 'value' => 'jeanne, jeannine, jeannette, jean-pierre et jean claude'
|
|
||||||
];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$record->set_metadatas($toupdate);
|
|
||||||
|
|
||||||
self::$searchEngine->addRecord($record);
|
|
||||||
$this->updateIndex();
|
|
||||||
|
|
||||||
$binaryFinder = new ExecutableFinder();
|
|
||||||
$indexer = $binaryFinder->find('indexer');
|
|
||||||
|
|
||||||
$appbox = self::$DI['app']['phraseanet.appbox'];
|
|
||||||
self::$searchEngine->buildSuggestions($appbox->get_databoxes(), self::$config, 0);
|
|
||||||
|
|
||||||
$process = new Process($indexer . ' --all --rotate -c ' . self::$config);
|
|
||||||
$process->run();
|
|
||||||
usleep(500000);
|
|
||||||
|
|
||||||
$suggestions = self::$searchEngine->autocomplete('jean', $this->options);
|
|
||||||
$this->assertInstanceOf('\\Doctrine\\Common\\Collections\\ArrayCollection', $suggestions);
|
|
||||||
|
|
||||||
$this->assertGreaterThan(2, count($suggestions));
|
|
||||||
|
|
||||||
foreach ($suggestions as $suggestion) {
|
|
||||||
$this->assertInstanceof('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineSuggestion', $suggestion);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function updateIndex(array $stemms = [])
|
|
||||||
{
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user