/** * Returns the current result * * @returns xfDocumentHit */ public function current() { $hit = $this->iterator->current(); // this response is pluggable, we must do error checking if (!$hit instanceof xfDocumentHit) { throw new xfResultException('Iterator for engine must return instances of xfDocumentHit, ' . gettype($hit) . ' given'); } $service = $this->registry->getService($hit->getServiceName()); $hit->setRetorts($service->getRetorts()); return $hit; }
require 'util/xfException.class.php'; require 'service/xfService.class.php'; require 'service/xfServiceRegistry.class.php'; require 'service/xfServiceException.class.php'; require 'service/xfServiceNotFoundException.class.php'; require 'service/xfServiceIgnoredException.class.php'; require 'document/xfField.class.php'; require 'document/xfFieldValue.class.php'; require 'document/xfDocument.class.php'; require 'mock/service/xfMockIdentifier.class.php'; $t = new lime_test(8, new lime_output_color()); $registry = new xfServiceRegistry(); $t->is($registry->getServices(), array(), '->getServices() is empty initially'); try { $msg = '->getService() fails if service does not exist'; $registry->getService('foo'); $t->fail($msg); } catch (Exception $e) { $t->pass($msg); } try { $msg = '->locate() fails if service does not exist'; $registry->locate('foo'); $t->fail($msg); } catch (Exception $e) { $t->pass($msg); } $identifier = new xfMockIdentifier(); $identifier->match = xfIdentifier::MATCH_NO; $service = new xfService($identifier); $registry->register($service);