/** * Retrieve a single document. * * @param string $id Document identifier * @param ParamBag $params Search backend parameters * * @return RecordCollectionInterface */ public function retrieve($id, ParamBag $params = null) { $response = $this->connector->getRecord($id, $params); $collection = $this->createRecordCollection($response); $this->injectSourceIdentifier($collection); return $collection; }
/** * Create the WorldCat connector. * * @return Connector */ protected function createConnector() { $wsKey = isset($this->config->WorldCat->apiKey) ? $this->config->WorldCat->apiKey : null; $connector = new Connector($wsKey, $this->serviceLocator->get('VuFind\\Http')->createClient()); $connector->setLogger($this->logger); return $connector; }
/** * Get holdings information from WorldCat (false if none available). * * @return \SimpleXMLElement|bool */ public function getHoldings() { $id = $this->getOCLCNum(); return empty($id) ? false : $this->wc->getHoldings($id); }
/** * Test search * * @return void */ public function testSearch() { $client = $this->getMock('Zend\\Http\\Client'); $connector = new Connector('key', $client); $client->expects($this->once())->method('setMethod')->with($this->equalTo('POST'))->will($this->returnValue($client)); $client->expects($this->once())->method('setUri')->with($this->equalTo('http://www.worldcat.org/webservices/catalog/search/sru?version=1.1&x=y&startRecord=0&maximumRecords=20&servicelevel=full&wskey=key')); $body = '<foo>,<numberOfRecords>1</numberOfRecords><records><record><recordData>bar</recordData></record></records></foo>'; $response = $this->getMock('Zend\\Http\\Response'); $response->expects($this->once())->method('getBody')->will($this->returnValue($body)); $response->expects($this->any())->method('isSuccess')->will($this->returnValue(true)); $client->expects($this->once())->method('send')->will($this->returnValue($response)); $final = $connector->search(new ParamBag(['x' => 'y']), 0, 20); $this->assertEquals('<recordData>bar</recordData>', $final['docs'][0]); $this->assertEquals(1, $final['total']); }