function DrupalSolrMultilingualConfigTestCase::testSolrRunningUsingMultilingualDefaultConfig in Apache Solr Multilingual 7
Same name and namespace in other branches
- 6.3 apachesolr_multilingual_confgen/tests/solr_multilingual.test \DrupalSolrMultilingualConfigTestCase::testSolrRunningUsingMultilingualDefaultConfig()
Test search indexing.
File
- apachesolr_multilingual_confgen/
tests/ solr_multilingual.test, line 34
Class
Code
function testSolrRunningUsingMultilingualDefaultConfig() {
$solr_version = '1.4.x';
$filesdir = variable_get('file_public_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) {
// workaround for drupal.org test bot
$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);
}