$t->pass('__construct() rejects invalid search instances'); } try { new sfLucenePropelIndexer($lucene, new Bar()); $t->fail('__construct() rejects unregistered models'); } catch (Exception $e) { $t->pass('__construct() rejects unregistered models'); } try { new sfLucenePropelIndexer($lucene, new Foo()); $t->fail('__construct() rejects non-Propel models'); } catch (Exception $e) { $t->pass('__construct() rejects non-Propel models'); } try { $indexer = new sfLucenePropelIndexer($lucene, $model); $t->pass('__construct() accepts valid search instances and valid models'); } catch (Exception $e) { $t->fail('__construct() accepts valid search instances and valid models'); } $t->diag('testing ->insert(), fields'); $h->get('fields')->get('title')->set('type', 'foobar'); try { $indexer->insert(); $t->fail('->insert() fails if a field has an invalid type'); } catch (Exception $e) { $t->pass('->insert() fails if a field has an invalid type'); } $h->get('fields')->get('title')->set('type', 'keyword'); $indexer->delete(); $indexer->insert();
$t->is(count($behavior->_getDeleteQueue()), 1, '::setLock() enables the delete queue'); $behavior->clear(); foreach (array($m1, $m2, $m3, $m3) as $m) { $indexer = new sfLucenePropelIndexer(sfLucene::getInstance('testLucene', 'en'), $m); $indexer->delete(); } $t->diag('testing ->insertIndex()'); $en = sfLucene::getInstance('testLucene', 'en'); $fr = sfLucene::getInstance('testLucene', 'fr'); foreach (array('en', 'fr') as $cult) { $indexer = new sfLucenePropelIndexer(${$cult}, $m1); $indexer->delete(); } $behavior->insertIndex($m1); $en->commit(); $fr->commit(); $t->is($en->numDocs(), 1, '->insertIndex() added model to first index it appears in'); $t->is($fr->numDocs(), 1, '->insertIndex() added model to second index it appears in'); $t->diag('testing ->deleteIndex();'); $behavior->deleteIndex($m1); $en->commit(); $fr->commit(); $t->is($en->numDocs(), 0, '->deleteIndex() deleted model from first index it appears in'); $t->is($fr->numDocs(), 0, '->deleteIndex() deleted model from second index it appears in'); foreach (array('en', 'fr') as $cult) { $indexer = new sfLucenePropelIndexer(${$cult}, $m1); $indexer->delete(); } $m1->delete(); $m2->delete(); $m3->delete();