/**
  * @see xfRetort
  */
 public function respond(xfDocumentHit $hit, $method, array $args = array())
 {
     $route = $this->template;
     foreach ($this->matches as $match) {
         $route = str_replace('$' . $match . '$', $hit->getDocument()->getField($match)->getValue(), $route);
     }
     return $route;
 }
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require dirname(__FILE__) . '/../../bootstrap/unit.php';
require 'util/xfException.class.php';
require 'document/xfDocument.class.php';
require 'document/xfField.class.php';
require 'document/xfFieldValue.class.php';
require 'result/xfDocumentHit.class.php';
require 'result/xfResultException.class.php';
require 'mock/result/xfMockRetort.class.php';
$t = new lime_test(11, new lime_output_color());
$document = new xfDocument('guid');
$document->addField(new xfFieldValue(new xfField('_service', xfField::STORED), 'foo-service'));
$hit = new xfDocumentHit($document, array('score' => 0.2));
$t->diag('->getOption(), ->getOptions(), hasOption(), setOption()');
$t->is($hit->getOption('score'), 0.2, '->getOption() returns the option value');
$t->is($hit->getOption('foobar'), null, '->getOption() returns null for unset options');
$t->is($hit->getOption('foobar', 42), 42, '->getOption() returns the default for unset options');
$t->ok($hit->hasOption('score'), '->hasOption() returns true for options that exist');
$t->ok(!$hit->hasOption('foobar'), '->hasOption() returns false for options that do not exist');
$hit->setOption('foobar', 'baz');
$t->is($hit->getOption('foobar'), 'baz', '->getOption() returns the option value');
$t->is($hit->getOptions(), array('score' => 0.2, 'foobar' => 'baz'), '->getOptions() returns all options');
$t->diag('->getDocument(), ->getServiceName()');
$t->is($hit->getDocument(), $document, '->getDocument() returns the wrapped document');
$t->is($hit->getServiceName(), 'foo-service', '->getServiceName() returns the service name');
$t->diag('->__call()');
$retort = new xfMockRetort();
$retort->can = false;
 /**
  * Processes a result
  *
  * @param xfDocumentHit $result
  * @param int $count
  * @param bool $verbose
  */
 private function processHit(xfDocumentHit $result, $count, $verbose = false)
 {
     $this->log('');
     $this->log($count . ') ' . $this->formatter->format($result->getDocument()->getGuid(), array('fg' => 'blue', 'bold' => true)) . ':');
     foreach ($result->getDocument()->getFields() as $field) {
         $this->processField($field, $verbose);
     }
     foreach ($result->getOptions() as $key => $value) {
         $this->outputRow($key, $value, 'red');
     }
 }
Exemplo n.º 4
0
 public function respond(xfDocumentHit $hit, $method, array $args = array())
 {
     return 'Description' . $hit->getDocument()->getField('input')->getValue();
 }
 /**
  * @see xfRetort
  */
 public function respond(xfDocumentHit $hit, $method, array $args = array())
 {
     $field = $this->normalize($method);
     return $hit->getDocument()->getField($field)->getValue();
 }