From c7ea17273b432c0c18b91b1338c15678a15cafa4 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Mon, 13 Jan 2014 14:06:51 -0500
Subject: [PATCH] Coverage improvement.

---
 .../VuFindTest/Backend/Solr/BackendTest.php   | 44 +++++++++++++++++--
 1 file changed, 40 insertions(+), 4 deletions(-)

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 f9105253cb5..d3c87e7a2e4 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.
      *
-- 
GitLab