From d3c6986984339edf83d144acabf5e0a76cb3a3af Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Tue, 9 Dec 2014 13:57:27 -0500
Subject: [PATCH] Added test.

---
 .../Recommend/WorldCatTermsTest.php           | 94 +++++++++++++++++++
 1 file changed, 94 insertions(+)
 create mode 100644 module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/WorldCatTermsTest.php

diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/WorldCatTermsTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/WorldCatTermsTest.php
new file mode 100644
index 00000000000..774ce677d0f
--- /dev/null
+++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/WorldCatTermsTest.php
@@ -0,0 +1,94 @@
+<?php
+/**
+ * WorldCatTerms recommendation module Test Class
+ *
+ * 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\Recommend;
+use VuFind\Recommend\WorldCatTerms;
+
+/**
+ * WorldCatTerms recommendation module Test Class
+ *
+ * @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 WorldCatTermsTest extends \VuFindTest\Unit\TestCase
+{
+    /**
+     * Test normal operation of the module.
+     *
+     * @return void
+     */
+    public function testNormalOperation()
+    {
+        $terms = array(
+            'exact' => 'exact', 'junk' => 'junk'
+        );
+        $wcu = $this->getMockWorldCatUtils();
+        $wcu->expects($this->once())->method('getRelatedTerms')
+            ->with($this->equalTo('foo'), $this->equalTo('lcsh'))
+            ->will($this->returnValue($terms));
+        $results = $this->getMockResults();
+        $request = new \Zend\StdLib\Parameters(array());
+        $module = new WorldCatTerms($wcu);
+        $module->setConfig('');
+        $module->init($results->getParams(), $request);
+        $module->process($results);
+        $this->assertEquals( array('exact' => 'exact'), $module->getTerms());
+    }
+
+    /**
+     * Get a mock WorldCatUtils object.
+     *
+     * @return \VuFind\Connection\WorldCatUtils
+     */
+    protected function getMockWorldCatUtils()
+    {
+        return $this->getMockBuilder('VuFind\Connection\WorldCatUtils')
+            ->disableOriginalConstructor()->getMock();
+    }
+
+    /**
+     * Get a mock results object.
+     *
+     * @return \VuFind\Search\Solr\Results
+     */
+    protected function getMockResults()
+    {
+        $query = new \VuFindSearch\Query\Query('foo', 'bar');
+        $params = $this->getMockBuilder('VuFind\Search\Solr\Params')
+            ->disableOriginalConstructor()->getMock();
+        $params->expects($this->any())->method('getQuery')
+            ->will($this->returnValue($query));
+        $results = $this->getMockBuilder('VuFind\Search\Solr\Results')
+            ->disableOriginalConstructor()->getMock();
+        $results->expects($this->any())->method('getParams')
+            ->will($this->returnValue($params));
+        return $results;
+    }
+}
\ No newline at end of file
-- 
GitLab