for ($i = 0; $i < 5; $i++) { $indexer->insert(); } $lucene->setParameter('delete_lock', true); $indexer->delete(); $lucene->commit(); $t->is($lucene->numDocs(), 5, '->delete() does nothing if parameter "delete_lock" is set'); $lucene->setParameter('delete_lock', false); $indexer->delete(); $lucene->commit(); $t->is($lucene->numDocs(), 0, '->delete() deletes all matching documents in the index'); $lucene->getCategoriesHarness()->getCategory('Cat1')->add(5); $h->set('categories', array('Cat1')); $indexer->insert(); $lucene->commit(); $count = $lucene->getCategoriesHarness()->getCategory('Cat1')->getCount(); $indexer->delete(); $t->is($lucene->getCategoriesHarness()->getCategory('Cat1')->getCount(), $count - 1, '->delete() updates the category database count'); $indexer->insert(); $count = $lucene->getCategoriesHarness()->getCategory('Cat1')->getCount(); $h->set('categories', array('Cat2')); $indexer->delete(); $t->is($lucene->getCategoriesHarness()->getCategory('Cat1')->getCount(), $count - 1, '->delete() updates category count that it was indexed with if categories have changed'); $t->is($lucene->getCategoriesHarness()->getCategory('Cat2')->getCount(), 0, '->delete() does not update new category count if categories have changed'); $t->diag('testing ->save()'); for ($i = 0; $i < 5; $i++) { $indexer->insert(); } $indexer->save(); $lucene->commit(); $t->is($lucene->numDocs(), 1, '->save() deletes all old instances and inserts only one new one');