/** * Returns an instance of Lucene that is supposed to be used for this app. */ public static function getApplicationInstance($culture = null) { $name = sfConfig::get('app_lucene_index', null); if (!$name) { $possible = sfLucene::getAllNames(); $name = current($possible); } if (!$name) { throw new sfLuceneException('A index to use could not be resolved'); } return sfLucene::getInstance($name, $culture); }
$t->is($new->numDocs(), 0, '->numDocs() indicates index is empty'); } else { $t->skip('index has new status new status on new index'); $t->skip('->numDocs() indicates index is empty'); } $t->diag('testing ::getAllInstances()'); try { $t->no_exception('::getAllInstance() executes without exception'); $instances = sfLucene::getAllInstances(); $e->no(); } catch (Exception $ex) { $instances = array(); $e->caught($ex); } $t->is_deeply($instances, array(sfLucene::getInstance('testLucene', 'en'), sfLucene::getInstance('testLucene', 'fr'), sfLucene::getInstance('fooLucene', 'en')), '::getAllInstances() returns all instances'); $t->is_deeply(sfLucene::getAllNames(), array('testLucene', 'fooLucene'), '::getAllNames() returns all configured names'); $t->diag('testing ->loadConfig()'); $h = $lucene->getParameterHolder(); $t->isa_ok($h, 'sfParameterHolder', '->getParameterHolder() returns a parameter holder'); $t->is($h->get('name'), 'testLucene', 'property "name" is the name of the index'); $t->is($h->get('culture'), 'en', 'property "culture" is the culture of the index'); $t->is($h->get('enabled_cultures'), array('en', 'fr'), 'property "enabled_cultures" contains all enabled cultures'); $t->like($h->get('index_location'), '#/index/testLucene/en$#', 'property "index_location" is the correct path'); $t->is($h->get('encoding'), 'UTF-8', 'property "encoding" is the encoding'); $t->is($h->get('stop_words'), array('and', 'the'), 'property "stop_words" contains the stop words'); $t->is($h->get('short_words'), 2, 'property "short_words" is the short word limit'); $t->is($h->get('mb_string'), true, 'property "mb_string" indicates if to use mb_string functions'); $t->isa_ok($h->get('models'), 'sfParameterHolder', 'property "models" is a sfParameterHolder'); $t->isa_ok($h->get('models')->get('FakeForum'), 'sfParameterHolder', 'properties of "models" are sfParameterHolders'); $m = $h->get('models')->get('FakeForum'); $t->is($m->get('title'), 'title', 'model property "title" is the correct title field');
$e->no(); } catch (Exception $ex) { $e->caught($ex); } $t->skip('->numDocs() TODO !! indicates index is empty'); $t->diag('testing ::getAllInstances()'); try { $e = $t->no_exception('::getAllInstance() executes without exception'); $instances = sfLucene::getAllInstances($app_configuration); $e->no(); } catch (Exception $ex) { $instances = array(); $e->caught($ex); } $t->is_deeply($instances, array(sfLucene::getInstance('index', 'en', $app_configuration), sfLucene::getInstance('index', 'fr', $app_configuration), sfLucene::getInstance('fooLucene', 'en', $app_configuration)), '::getAllInstances() returns all instances'); $t->is_deeply(sfLucene::getAllNames($app_configuration), array('index', 'fooLucene'), '::getAllNames() returns all configured names'); $t->diag('testing ->loadConfig()'); $lucene = sfLucene::getInstance('index', 'en', $app_configuration); $h = $lucene->getParameterHolder(); $t->isa_ok($h, 'sfParameterHolder', '->getParameterHolder() returns a parameter holder'); $t->is($h->get('name'), 'index', 'property "name" is the name of the index'); $t->is($h->get('culture'), 'en', 'property "culture" is the culture of the index'); $t->is($h->get('enabled_cultures'), array('en', 'fr'), 'property "enabled_cultures" contains all enabled cultures'); $t->is($h->get('encoding'), 'UTF-8', 'property "encoding" is the encoding'); $t->is($h->get('mb_string'), true, 'property "mb_string" indicates if to use mb_string functions'); $t->isa_ok($h->get('models'), 'sfParameterHolder', 'property "models" is a sfParameterHolder'); $t->isa_ok($h->get('models')->get('FakeForum'), 'sfParameterHolder', 'properties of "models" are sfParameterHolders'); $m = $h->get('models')->get('FakeForum'); $t->is($m->get('title'), 'title', 'model property "title" is the correct title field'); $t->is($m->get('description'), 'description', 'model property "description" is the correct description field'); $t->is($m->get('categories'), array('Forum'), 'model property "categories" contains the correct categories');