diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/BackendTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/BackendTest.php index f9105253cb53287d4db37b210f6db29b07fa1b7a..d3c87e7a2e45a310cf884cb24a1e41ca775b455e 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/BackendTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/BackendTest.php @@ -217,16 +217,54 @@ class BackendTest extends PHPUnit_Framework_TestCase } /** - * Test refining an alphabrowse exception. + * Test refining an alphabrowse exception (string 1). * * @return void * @expectedException VuFindSearch\Backend\Exception\RemoteErrorException * @expectedExceptionMessage Alphabetic Browse index missing. */ public function testRefineAlphaBrowseException() + { + $this->runRefineExceptionCall('does not exist'); + } + + /** + * Test refining an alphabrowse exception (string 2). + * + * @return void + * @expectedException VuFindSearch\Backend\Exception\RemoteErrorException + * @expectedExceptionMessage Alphabetic Browse index missing. + */ + public function testRefineAlphaBrowseExceptionWithAltString() + { + $this->runRefineExceptionCall('couldn\'t find a browse index'); + } + + /** + * Test that we don't refine a non-alphabrowse-related exception. + * + * @return void + * @expectedException VuFindSearch\Backend\Exception\RemoteErrorException + * @expectedExceptionMessage not a browse error + */ + public function testRefineAlphaBrowseExceptionWithNonBrowseString() + { + $this->runRefineExceptionCall('not a browse error'); + } + + /// Internal API + + /** + * Support method to run a "refine exception" test. + * + * @param string $msg Error message + * + * @return void + */ + protected function runRefineExceptionCall($msg) { $conn = $this->getConnectorMock(array('query')); - $e = new RemoteErrorException('does not exist', 400, new \Zend\Http\Response()); + $e = new RemoteErrorException($msg, 400, new \Zend\Http\Response()); $conn->expects($this->once())->method('query') ->with($this->equalTo('browse')) ->will($this->throwException($e)); @@ -234,8 +272,6 @@ class BackendTest extends PHPUnit_Framework_TestCase $back->alphabeticBrowse('foo', 'bar', 1); } - /// Internal API - /** * Load a SOLR response as fixture. *