示例#1
0
文件: Backend.php 项目: tillk/vufind
 /**
  * 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;
 }
示例#2
0
 /**
  * Test "get record" with error
  *
  * @return void
  */
 public function testGetRecordWithError()
 {
     $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/content/baz?servicelevel=full&wskey=key'));
     $body = '<foo><diagnostic>bad</diagnostic></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->getRecord('baz');
     $this->assertEquals([], $final['docs']);
 }