diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/SearchServiceTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/SearchServiceTest.php index 566561ccfc1c65c2387d5c9eadbcc6bb90bc14e4..a09096deef9af406f278ddc546dfa3548bba554c 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/SearchServiceTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/SearchServiceTest.php @@ -34,6 +34,7 @@ use VuFindSearch\ParamBag; use VuFindSearch\Backend\BackendInterface; use VuFindSearch\Backend\Exception\BackendException; use VuFindSearch\Feature\RetrieveBatchInterface; +use VuFindSearch\Query\Query; use VuFindSearch\Response\AbstractRecordCollection; use PHPUnit_Framework_TestCase as TestCase; @@ -102,6 +103,28 @@ class SearchServiceTest extends TestCase $service->retrieve('foo', 'bar', $params); } + /** + * Test exception-throwing search action. + * + * @return void + * @expectedException VuFindSearch\Backend\Exception\BackendException + * @expectedExceptionMessage test + */ + public function testSearchException() + { + $service = $this->getService(); + $backend = $this->getBackend(); + $exception = new BackendException('test'); + $backend->expects($this->once())->method('search') + ->will($this->throwException($exception)); + $em = $service->getEventManager(); + $em->expects($this->at(0))->method('trigger') + ->with($this->equalTo('pre'), $this->equalTo($backend)); + $em->expects($this->at(1))->method('trigger') + ->with($this->equalTo('error'), $this->equalTo($exception)); + $service->search('foo', new Query('test')); + } + /** * Test batch retrieve (with RetrieveBatchInterface). *