/**
  * Gets the partial specified for this result.
  */
 public function getInternalPartial($module = 'sfLucene')
 {
     $model = $this->retrieveModel();
     if ($model->get('partial')) {
         return $model->get('partial');
     }
     return parent::getInternalPartial($module);
 }
 /**
  * Gets a result instance for the result.
  */
 protected function getInstance($result)
 {
     return sfLuceneResult::getInstance($result, $this->search);
 }
示例#3
0
$mockresult->score = 0.425;
$mockresult->id = 1;
$t->diag('testing constructor');
try {
    $ex = $t->no_exception('__construct() accepts a valid result and valid sfLucene instance');
    new sfLuceneResult($mockresult, $lucene);
    $ex->no();
} catch (Exception $e) {
    $ex->caught($e);
}
$mockresult->sfl_type = 'action';
$t->isa_ok(sfLuceneResult::getInstance($mockresult, $lucene), 'sfLuceneActionResult', '::getInstance() returns an instance of sfLuceneActionResult for "type" = action');
$mockresult->sfl_type = 'model';
$t->isa_ok(sfLuceneResult::getInstance($mockresult, $lucene), 'sfLuceneDoctrineResult', '::getInstance() returns an instance of sfLuceneModelResult for "type" = model');
$mockresult->sfl_type = 'regular';
$result = sfLuceneResult::getInstance($mockresult, $lucene);
$t->isa_ok($result, 'sfLuceneResult', '::getInstance() returns an instance of sfLuceneResult for "type" = regular');
$t->diag('testing ->getSearch(), ->getResult()');
$t->is($result->getSearch(), $lucene, '->getSearch() returns the same instance of sfLucene as initialized with');
$t->is($result->getResult(), $mockresult, '->getResult() returns the same instace of the result as initialized with');
$t->diag('testing simple ->get*()');
$t->is($result->getScore(), 43, '->getScore() gets the percentage from decimal and rounds');
$t->is($result->getInternalPartial(), 'sfLucene/regularResult', '->getInternalPartial() returns the correct partial name');
$t->diag('testing dynamic ->getXXX()');
$mockresult->sequence = '123';
$t->is($result->getSequence(), '123', '->getXXX() returns property XXX on document');
$t->ok($result->hasSequence(), '->hasXXX() returns true if document has property XXX');
$mockresult->super_duper_man = 'Fabien Potencier';
$t->is($result->getSuperDuperMan(), 'Fabien Potencier', '->getXXX() returns property XXX for camel case');
$t->ok($result->hasSuperDuperMan(), '->hasXXX() returns if document has property XXX for camel case');
try {