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

Improved test coverage.

parent 01d6aa2d
No related merge requests found
......@@ -131,6 +131,56 @@ class BackendTest extends \VuFindTest\Unit\TestCase
$this->assertEquals($conn, $back->getConnector());
}
/**
* Test search exception handling.
*
* @return void
* @expectedException VuFindSearch\Backend\Exception\BackendException
*/
public function testSearchWrapsPrimoException()
{
$conn = $this->getConnectorMock(array('query'));
$conn->expects($this->once())
->method('query')
->will($this->throwException(new \Exception()));
$back = new Backend($conn);
$back->search(new Query(), 1, 1);
}
/**
* Test retrieve exception handling.
*
* @return void
* @expectedException VuFindSearch\Backend\Exception\BackendException
*/
public function testRetrieveWrapsPrimoException()
{
$conn = $this->getConnectorMock(array('getRecord'));
$conn->expects($this->once())
->method('getRecord')
->will($this->throwException(new \Exception()));
$back = new Backend($conn);
$back->retrieve('1234');
}
/**
* Test merged param bag.
*
* @return void
*/
public function testMergedParamBag()
{
$myParams = new ParamBag(array('foo' => 'bar'));
$expectedParams = array('foo' => 'bar', 'limit' => 10, 'pageNumber' => 1.0, 'query' => array(array('index' => null, 'lookfor' => 'baz')));
$conn = $this->getConnectorMock(array('query'));
$conn->expects($this->once())
->method('query')
->with($this->equalTo('inst-id'), $this->equalTo($expectedParams['query']), $this->equalTo($expectedParams))
->will($this->returnValue(array('recordCount' => 0, 'documents' => array())));
$back = new Backend($conn);
$back->search(new Query('baz'), 0, 10, $myParams);
}
/// Internal API
/**
......
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