define('LOCATION', dirname(__FILE__) . '/../../sandbox/index');
if (is_dir(LOCATION)) {
    // clear the old index first
    foreach (new DirectoryIterator(LOCATION) as $file) {
        if ($file->isDot()) {
            continue;
        }
        unlink($file->getRealpath());
    }
} else {
    mkdir(LOCATION, 0777, true);
}
$t = new lime_test(69, new lime_output_color());
$engine = new xfLuceneEngine(LOCATION);
$t->diag('->open(), ->close()');
$engine->open();
$index = $engine->getIndex();
$t->isa_ok($index, 'Zend_Search_Lucene', '->open() opens the index');
$engine->open();
$t->ok($index === $engine->getIndex(), '->open() does not open another index if it is already open');
$engine->close();
try {
    $msg = '->close() closes the index';
    $engine->getIndex();
    $t->fail($msg);
} catch (Exception $e) {
    $t->pass($msg);
}
$engine->open();
$t->isa_ok($engine->getIndex(), 'Zend_Search_Lucene', '->open() can reopen the index');
$t->diag('->getAnalyzer(), ->setAnalyzer()');