Skip to content
Snippets Groups Projects
Commit c042de04 authored by Demian Katz's avatar Demian Katz
Browse files

More coverage.

parent b571f01b
No related merge requests found
......@@ -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']);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment