{
        $this->rebuilds[] = $name;
    }
}
$search = sfLucene::getInstance('testLucene', 'en');
$t->diag('testing ->rebuild()');
$handler = new FooIndexer($search);
$handler->rebuild();
$t->is($handler->rebuilds, array('FakeForum'), '->rebuild() calls ->rebuildModel() for all models');
$t->diag('testing ->rebuildModel()');
$handler = new sfLucenePropelIndexerHandler($search);
$search->getParameter('models')->get('FakeForum')->set('rebuild_limit', 5);
$models = array();
for ($x = 0; $x < 6; $x++) {
    $var = new FakeForum();
    $var->setCulture('en');
    $var->setTitle('foo');
    $var->setDescription('bar');
    $var->setCoolness(3);
    $var->save();
    $var->deleteIndex();
    $models[] = $var;
}
$search->commit();
$t->is($search->numDocs(), 0, 'model setup leaves index empty');
$handler->rebuildModel('FakeForum');
$search->commit();
$t->is($search->numDocs(), count($models), '->rebuildModel() builds all models');
foreach ($models as $model) {
    $model->delete();
}
<?php

/*
 * This file is part of the sfLucenePlugin package
 * (c) 2007 - 2008 Carl Vondrick <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
/**
 * @package sfLucenePlugin
 * @subpackage Test
 * @author Carl Vondrick
 * @version SVN: $Id: sfLuceneLazyLoadingTest.php 7108 2008-01-20 07:44:42Z Carl.Vondrick $
 */
require dirname(__FILE__) . '/../bootstrap/unit.php';
$t = new limeade_test(2, limeade_output::get());
$limeade = new limeade_sf($t);
$limeade->bootstrap();
$luceneade = new limeade_lucene($limeade);
$luceneade->configure()->clear_sandbox()->load_models();
$forum = new FakeForum();
$t->not_like_included('#/Zend/Search/Lucene/#', 'Zend libraries were not loaded when just reading from a model');
$forum->setTitle('test');
$forum->saveIndex();
$t->like_included('#/Zend/Search/Lucene/#', 'Zend libraries were loaded when writing to the index');
$forum->deleteIndex();
$t->todo('field type "Unstored" is not stored');
$t->todo('field type "Unstored" is indexed');
$t->todo('field type "Unstored" is tokenized');
$t->todo('field type "Unstored" is not binary');
$h->get('fields')->get('title')->set('type', 'text');
$indexer->delete();
$indexer->insert();
$lucene->commit();
$doc = getDoc($lucene, $indexer->getModelGuid());
$t->ok($doc->getDocument()->getField('title')->isStored, 'field type "Keyword" is stored');
$t->ok($doc->getDocument()->getField('title')->isIndexed, 'field type "Keyword" is indexed');
$t->ok($doc->getDocument()->getField('title')->isTokenized, 'field type "Keyword" is tokenized');
$t->ok(!$doc->getDocument()->getField('title')->isBinary, 'field type "Keyword" is not binary');
$indexer->delete();
$t->diag('testing ->insert(), document fields');
$model->setTitle('foobar!');
try {
    $indexer->insert();
    $lucene->commit();
    $doc = getDoc($lucene, $indexer->getModelGuid());
    $t->is($doc->title, 'foobar!', '->insert() handles strings from field getters');
} catch (Exception $e) {
    $t->fail('->insert() handles strings from field getters');
}
$ph = new sfParameterHolder();
$ph->add(array('type' => 'text', 'boost' => 1));
$h->get('fields')->set('nonScalar', $ph);
try {
    $indexer->insert();
    $t->fail('->insert() fails if field getter does not return a scalar');
} catch (Exception $e) {