View source
<?php
class DrupalSolrMultilingualConfigTestCase extends AbstractDrupalSolrOnlineWebTestCase {
public static function getInfo() {
return array(
'name' => 'Solr Multilingual',
'description' => 'Indexes multilingual content and queries it.',
'group' => 'ApacheSolr Multilingual',
);
}
function setUp() {
parent::setUp('locale', 'variable', 'i18n', 'i18nstrings', 'querypath', 'apachesolr_multilingual', 'apachesolr_multilingual_confgen', 'apachesolr_confgen_textfiles');
querypath_boot();
}
function testSolrRunningUsingMultilingualDefaultConfig() {
$solr_version = '1.4.x';
$filesdir = file_directory_path();
mkdir("{$filesdir}/solr_multlingual", 0777, TRUE);
$filesdir = realpath("{$filesdir}/solr_multlingual");
$files = array();
foreach (array(
'currency',
'elevate',
'schema',
'solrconfig',
) as $file) {
if ('currency' == $file && strpos($solr_version, '1.') === 0) {
continue;
}
$qp = apachesolr_confgen_get_original_qp($file, $solr_version);
drupal_alter('apachesolr_confgen_' . $file, $qp, $solr_version);
$files[$file . '.xml'] = $qp
->find(':root')
->xml();
}
drupal_alter('apachesolr_confgen_zip_file', $files, $solr_version);
$assert_files = array(
'solrconfig.xml',
'schema.xml',
'elevate.xml',
);
foreach ($assert_files as $file_name) {
$this
->assertTrue(array_key_exists($file_name, $files), 'Verify existence of ' . $file_name);
}
$assert_multilingual_files = array(
'compoundwords.txt',
'mapping-ISOLatin1Accent.txt',
'protwords.txt',
'stopwords.txt',
'synonyms.txt',
);
$language_ids = array_keys(apachesolr_multilingual_language_list());
$language_ids[] = '';
foreach ($assert_multilingual_files as $file_name) {
foreach ($language_ids as $language_id) {
$i18n_file_name = !empty($language_id) ? str_replace('.txt', '_' . $language_id . '.txt', $file_name) : $file_name;
$this
->assertTrue(array_key_exists($file_name, $files), 'Verify existence of ' . $i18n_file_name);
}
}
foreach ($files as $file_name => $file_data) {
file_put_contents($filesdir . '/' . $file_name, $file_data);
}
parent::setUpSolr($filesdir . '/*');
if ($this->solr_available) {
$this
->assertTrue($this->solr
->ping(), "Verify solr server started with multilingual configuration");
$response = $this->solr
->search("*:*", array(
'qt' => 'standard',
));
$response = $response->response;
$this
->assertEqual($response->numFound, 0, "There should not be any documents in the index");
}
unset($filesdir);
}
}