diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/WorldCat/ConnectorTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/WorldCat/ConnectorTest.php index 763751567b65525885bf653152298e5ae086f7ce..2f47e2c04821d6c4ecfc1e2778d02ef05a8241a9 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/WorldCat/ConnectorTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/WorldCat/ConnectorTest.php @@ -30,6 +30,7 @@ namespace VuFindTest\Backend\WorldCat; use VuFindSearch\Backend\WorldCat\Connector; +use VuFindSearch\ParamBag; /** * Unit tests for WorldCat backend. @@ -140,4 +141,29 @@ class ConnectorTest extends \PHPUnit_Framework_TestCase $final = $connector->getRecord('baz'); $this->assertEquals(array(), $final['docs']); } + + /** + * 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)); + $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(), 0, 20); + $this->assertEquals('<recordData>bar</recordData>', $final['docs'][0]); + $this->assertEquals(1, $final['total']); + } }