From d080941bd25ebe69740d530f70f8765c01dd7b06 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Thu, 9 Oct 2014 14:40:11 -0400
Subject: [PATCH] Fixed inconsistency between @return and behavior. - Began
 test suite.

---
 .../Controller/Plugin/ResultScroller.php      |  2 +-
 .../Controller/Plugin/ResultScrollerTest.php  | 91 +++++++++++++++++++
 2 files changed, 92 insertions(+), 1 deletion(-)
 create mode 100644 module/VuFind/tests/unit-tests/src/VuFindTest/Controller/Plugin/ResultScrollerTest.php

diff --git a/module/VuFind/src/VuFind/Controller/Plugin/ResultScroller.php b/module/VuFind/src/VuFind/Controller/Plugin/ResultScroller.php
index 3939abf8441..6198ee3c8d2 100644
--- a/module/VuFind/src/VuFind/Controller/Plugin/ResultScroller.php
+++ b/module/VuFind/src/VuFind/Controller/Plugin/ResultScroller.php
@@ -80,7 +80,7 @@ class ResultScroller extends AbstractPlugin
     {
         // Do nothing if disabled:
         if (!$this->enabled) {
-            return;
+            return false;
         }
 
         // Save the details of this search in the session
diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Controller/Plugin/ResultScrollerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Controller/Plugin/ResultScrollerTest.php
new file mode 100644
index 00000000000..ec44cd34e8d
--- /dev/null
+++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Controller/Plugin/ResultScrollerTest.php
@@ -0,0 +1,91 @@
+<?php
+
+/**
+ * ResultScroller controller plugin tests.
+ *
+ * PHP version 5
+ *
+ * Copyright (C) Villanova University 2010.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * @category VuFind2
+ * @package  Tests
+ * @author   Demian Katz <demian.katz@villanova.edu>
+ * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
+ * @link     http://vufind.org/wiki/vufind2:unit_tests Wiki
+ */
+namespace VuFindTest\Controller\Plugin;
+
+use VuFind\Controller\Plugin\ResultScroller;
+use VuFindTest\Unit\TestCase as TestCase;
+
+/**
+ * ResultScroller controller plugin tests.
+ *
+ * @category VuFind2
+ * @package  Tests
+ * @author   Demian Katz <demian.katz@villanova.edu>
+ * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
+ * @link     http://vufind.org/wiki/vufind2:unit_tests Wiki
+ */
+class ResultScrollerTest extends TestCase
+{
+    /**
+     * Test disabled behavior
+     *
+     * @return void
+     */
+    public function testDisabled()
+    {
+        $plugin = new ResultScroller(false);
+        $this->assertFalse($plugin->init($this->getMockResults()));
+        $expected = array(
+            'previousRecord'=>null, 'nextRecord'=>null,
+            'currentPosition'=>null, 'resultTotal'=>null
+        );
+        $this->assertEquals($expected, $plugin->getScrollData($this->getMockRecordDriver('foo')));
+    }
+
+    /**
+     * Get mock record driver
+     *
+     * @param string $id     ID
+     * @param string $source Backend
+     *
+     * @return \VuFind\RecordDriver\AbstractBase
+     */
+    protected function getMockRecordDriver($id, $source = 'VuFind')
+    {
+        $driver = $this->getMockBuilder('VuFind\RecordDriver\AbstractBase')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $driver->expects($this->any())->method('getUniqueId')->will($this->returnValue($id));
+        $driver->expects($this->any())->method('getResourceSource')->will($this->returnValue($source));
+        return $driver;
+    }
+
+    /**
+     * Get mock search results
+     *
+     * @return \VuFind\Search\Base\Results
+     */
+    protected function getMockResults()
+    {
+        $results = $this->getMockBuilder('VuFind\Search\Solr\Results')
+            ->disableOriginalConstructor()
+            ->getMock();
+        return $results;
+    }
+}
\ No newline at end of file
-- 
GitLab