class FakeForum extends BaseFakeForum
{
    public $shouldIndex = true;
    public function isIndexable()
    {
        return $this->shouldIndex;
    }
    public function getNonScalar()
    {
        return range(1, 100);
    }
    public function getStringableObject()
    {
        return new Stringable();
    }
    public function getZendDocument()
    {
        $doc = new Zend_Search_Lucene_Document();
        $doc->addField(Zend_Search_Lucene_Field::Keyword('callback', 'foo'));
        return $doc;
    }
}
class Stringable
{
    public function __toString()
    {
        return 'Strings!';
    }
}
sfLucenePropelBehavior::getInitializer()->setup('FakeForum');
Beispiel #2
0
    }
    //for lucene index
    public function getContributor()
    {
        return $this->getUserId() ? $this->getSfGuardUser()->getUsername() : $this->getName();
    }
    public function save($con = null)
    {
        $highlighted = myUtils::highlight($this->getRawBody());
        $this->setBody($highlighted['body']);
        foreach ($this->getSnippetLanguages() as $language) {
            $language->delete();
        }
        foreach ($highlighted['langs'] as $lang => $count) {
            $sl = new SnippetLanguage();
            $sl->setName($lang);
            $sl->setSnippet($this);
            $this->addSnippetLanguage($sl);
        }
        $summarizer = new Summarizer(400);
        $this->setSummary($summarizer->summarize($this->getBody()));
        parent::save();
    }
    public function isIndexable()
    {
        return !$this->getDraft();
    }
}
sfLucenePropelBehavior::getInitializer()->setupModel('Snippet');
sfPropelBehavior::add('Snippet', array('sfPropelActAsRatableBehavior' => array('rating_field' => 'AverageRating')));
sfPropelBehavior::add('Snippet', array('sfPropelFriendlyUrlBehavior' => array('source_column' => 'title', 'target_column' => 'stripped_title')));
 /**
  * Locks the Propel behavior, so nothing can be queued.
  * @param bool $to If true, the behavior is locked.  If false, the behavior is unlocked.
  */
 public static function setLock($to)
 {
     self::$locked = (bool) $to;
 }
$search->commit();
$t->is($search->numDocs(), 1, '->postDelete() does not delete if it is not in the queue');
$behavior->postDelete($m1);
$search->commit();
$t->is($search->numDocs(), 0, '->postDelete() deletes the model from the index if it exists in the queue');
$t->is($behavior->_getDeleteQueue(), array(1 => $m2), '->postDelete() removes deleting model from the queue');
$t->diag('testing ::setLock()');
$behavior->clear();
sfLucenePropelBehavior::setLock(true);
$m1->setCoolness(4);
$behavior->preSave($m1);
$t->is(count($behavior->_getSaveQueue()), 0, '::setLock() disables the save queue');
$behavior->preDelete($m1);
$t->is(count($behavior->_getDeleteQueue()), 0, '::setLock() disables the delete queue');
$behavior->clear();
sfLucenePropelBehavior::setLock(false);
$behavior->preSave($m1);
$t->is(count($behavior->_getSaveQueue()), 1, '::setLock() enables the save queue');
$behavior->preDelete($m1);
$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();