/** * Get a Record object ready for testing. * * @param \VuFind\RecordDriver\AbstractBase $driver Record driver * @param array|Config $config Configuration * @param \VuFind\View\Helper\Root\Context $context Context helper * @param bool|string $url Should we add a URL helper? False if no, expected route if yes. * @param bool $serverurl Should we add a ServerURL helper? * * @return Record */ protected function getRecord($driver, $config = [], $context = null, $url = false, $serverurl = false) { if (null === $context) { $context = $this->getMockContext(); } $view = $this->getMock('Zend\\View\\Renderer\\PhpRenderer'); if ($url) { $url = $this->getMockUrl($url); } if (false !== $serverurl) { $serverurl = $this->getMockServerUrl(); } $pluginCallback = function ($helper) use($context, $url, $serverurl) { switch ($helper) { case 'context': return $context; case 'serverurl': return $serverurl; case 'url': return $url; case 'searchTabs': return $this->getMockSearchTabs(); default: return null; } }; $view->expects($this->any())->method('plugin')->will($this->returnCallback($pluginCallback)); $view->expects($this->any())->method('resolver')->will($this->returnValue($this->getMockResolver())); $config = is_array($config) ? new \Zend\Config\Config($config) : $config; $record = new Record($config); $record->setCoverRouter(new \VuFind\Cover\Router('http://foo/bar')); $record->setView($view); return $record->__invoke($driver); }
/** * Construct the Record helper. * * @param ServiceManager $sm Service manager. * * @return Record */ public static function getRecord(ServiceManager $sm) { $helper = new Record($sm->getServiceLocator()->get('VuFind\\Config')->get('config')); $helper->setCoverRouter($sm->getServiceLocator()->get('VuFind\\Cover\\Router')); return $helper; }