mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
Improve unit tests
This commit is contained in:
@@ -598,21 +598,18 @@ class ConfigurationPanel extends AbstractConfigurationPanel
|
||||
|
||||
index docs_realtime_stemmed_en_' . $index_crc . ' : docs_realtime_stemmed_fr_' . $index_crc . '
|
||||
{
|
||||
type = rt
|
||||
morphology = libstemmer_en
|
||||
path = /var/sphinx/datas/docs_realtime_stemmed_en_' . $index_crc . '
|
||||
}
|
||||
|
||||
index docs_realtime_stemmed_de_' . $index_crc . ' : docs_realtime_stemmed_fr_' . $index_crc . '
|
||||
{
|
||||
type = rt
|
||||
morphology = libstemmer_de
|
||||
path = /var/sphinx/datas/docs_realtime_stemmed_de_' . $index_crc . '
|
||||
}
|
||||
|
||||
index docs_realtime_stemmed_nl_' . $index_crc . ' : docs_realtime_stemmed_fr_' . $index_crc . '
|
||||
{
|
||||
type = rt
|
||||
morphology = libstemmer_nl
|
||||
path = /var/sphinx/datas/docs_realtime_stemmed_nl_' . $index_crc . '
|
||||
}
|
||||
|
@@ -301,6 +301,13 @@ class SphinxSearchEngine implements SearchEngineInterface
|
||||
"metadatas" . $CRCdatabox . "_stemmed_de",
|
||||
"metadatas" . $CRCdatabox . "_stemmed_nl",
|
||||
);
|
||||
$RTindexes = array(
|
||||
"metas_realtime" . $CRCdatabox,
|
||||
"metas_realtime_stemmed_fr_" . $CRCdatabox,
|
||||
"metas_realtime_stemmed_en_" . $CRCdatabox,
|
||||
"metas_realtime_stemmed_nl_" . $CRCdatabox,
|
||||
"metas_realtime_stemmed_de_" . $CRCdatabox,
|
||||
);
|
||||
|
||||
foreach ($record->get_caption()->get_fields(null, true) as $field) {
|
||||
|
||||
@@ -310,7 +317,9 @@ class SphinxSearchEngine implements SearchEngineInterface
|
||||
$this->sphinx->UpdateAttributes($index, array("deleted"), array($value->getId() => array(1)));
|
||||
}
|
||||
|
||||
$this->rt_conn->exec("DELETE FROM metas_realtime" . $CRCdatabox . " WHERE id = " . $value->getId());
|
||||
foreach ($RTindexes as $index) {
|
||||
$this->rt_conn->exec("DELETE FROM " . $index . " WHERE id = " . $value->getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,16 +330,21 @@ class SphinxSearchEngine implements SearchEngineInterface
|
||||
"documents" . $CRCdatabox . "_stemmed_de",
|
||||
"documents" . $CRCdatabox . "_stemmed_nl"
|
||||
);
|
||||
$RTindexes = array(
|
||||
"docs_realtime" . $CRCdatabox,
|
||||
"docs_realtime_stemmed_fr_" . $CRCdatabox,
|
||||
"docs_realtime_stemmed_en_" . $CRCdatabox,
|
||||
"docs_realtime_stemmed_nl_" . $CRCdatabox,
|
||||
"docs_realtime_stemmed_de_" . $CRCdatabox,
|
||||
);
|
||||
|
||||
foreach ($indexes as $index) {
|
||||
$this->sphinx->UpdateAttributes($index, array("deleted"), array($record->get_record_id() => array(1)));
|
||||
}
|
||||
|
||||
$this->rt_conn->exec("DELETE FROM docs_realtime" . $CRCdatabox . " WHERE id = " . $record->get_record_id());
|
||||
$this->rt_conn->exec("DELETE FROM docs_realtime_stemmed_fr_" . $CRCdatabox . " WHERE id = " . $record->get_record_id());
|
||||
$this->rt_conn->exec("DELETE FROM docs_realtime_stemmed_en_" . $CRCdatabox . " WHERE id = " . $record->get_record_id());
|
||||
$this->rt_conn->exec("DELETE FROM docs_realtime_stemmed_de_" . $CRCdatabox . " WHERE id = " . $record->get_record_id());
|
||||
$this->rt_conn->exec("DELETE FROM docs_realtime_stemmed_nl_" . $CRCdatabox . " WHERE id = " . $record->get_record_id());
|
||||
foreach ($RTindexes as $index) {
|
||||
$this->rt_conn->exec("DELETE FROM " . $index . " WHERE id = " . $record->get_record_id());
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@@ -498,7 +498,7 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA
|
||||
$record = self::$DI['record_24'];
|
||||
$query_string = 'boomboklot' . $record->get_record_id() . 'deleteRecord';
|
||||
|
||||
$this->editRecord($query_string, $record);
|
||||
$field = $this->editRecord($query_string, $record);
|
||||
|
||||
self::$searchEngine->addRecord($record);
|
||||
$this->updateIndex();
|
||||
@@ -508,6 +508,48 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA
|
||||
self::$searchEngine->resetCache();
|
||||
$results = self::$searchEngine->query($query_string, 0, 1);
|
||||
$this->assertEquals(0, $results->getTotal());
|
||||
|
||||
$options = $this->getDefaultOptions();
|
||||
$options->setFields(array($field));
|
||||
self::$searchEngine->setOptions($options);
|
||||
|
||||
self::$searchEngine->resetCache();
|
||||
$results = self::$searchEngine->query($query_string, 0, 1);
|
||||
$this->assertEquals(0, $results->getTotal());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideStemmData
|
||||
*/
|
||||
public function testDeleteRecordWithinStemmContext($language, $word, $stemm)
|
||||
{
|
||||
$record = self::$DI['record_24'];
|
||||
$index_string = 'boomboklot' . $record->get_record_id() . 'deleteRecordInStemmContext '.$word;
|
||||
$query_string = 'boomboklot' . $record->get_record_id() . 'deleteRecordInStemmContext '.$stemm;
|
||||
|
||||
$options = $this->getDefaultOptions();
|
||||
$options->setStemming(true);
|
||||
$options->setLocale($language);
|
||||
|
||||
self::$searchEngine->setOptions($options);
|
||||
|
||||
$field = $this->editRecord($index_string, $record);
|
||||
|
||||
self::$searchEngine->addRecord($record);
|
||||
$this->updateIndex();
|
||||
self::$searchEngine->removeRecord($record);
|
||||
$this->updateIndex();
|
||||
|
||||
self::$searchEngine->resetCache();
|
||||
$results = self::$searchEngine->query($query_string, 0, 1);
|
||||
$this->assertEquals(0, $results->getTotal());
|
||||
|
||||
$options->setFields(array($field));
|
||||
self::$searchEngine->setOptions($options);
|
||||
|
||||
self::$searchEngine->resetCache();
|
||||
$results = self::$searchEngine->query($query_string, 0, 1);
|
||||
$this->assertEquals(0, $results->getTotal());
|
||||
}
|
||||
|
||||
public function testAvailableTypes()
|
||||
|
Reference in New Issue
Block a user