/** * Store a record driver object and return this object so that the appropriate * template can be rendered. * * @param \VuFind\RecordDriver\AbstractBase|string $driver Record * driver object or record id. * * @return Record */ public function __invoke($driver) { if (is_string($driver)) { $driver = $this->loader->load($driver); } return parent::__invoke($driver); }
/** * 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; 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->setView($view); return $record->__invoke($driver); }
/** * 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 timing + : + expected route if yes. * @param bool|int $serverurl Should we add a ServerURL helper? False if no, expected timing if yes. * * @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'); $view->expects($this->at(0))->method('plugin')->with($this->equalTo('context'))->will($this->returnValue($context)); if ($url) { list($at, $route) = explode(':', $url); $view->expects($this->at($at))->method('plugin')->with($this->equalTo('url'))->will($this->returnValue($this->getMockUrl($route))); } if (false !== $serverurl) { $view->expects($this->at($serverurl))->method('plugin')->with($this->equalTo('serverurl'))->will($this->returnValue($this->getMockServerUrl())); } $config = is_array($config) ? new \Zend\Config\Config($config) : $config; $record = new Record($config); $record->setView($view); return $record->__invoke($driver); }