Skip to content
Snippets Groups Projects
Commit 1b228bef authored by Demian Katz's avatar Demian Katz
Browse files

Merge branch 'release-4.1'

parents 5bb57255 f3b9e638
No related merge requests found
......@@ -92,8 +92,8 @@ class ResultScroller extends AbstractPlugin
*/
public function init($searchObject)
{
// Do nothing if disabled:
if (!$this->enabled) {
// Do nothing if disabled or search is empty:
if (!$this->enabled || $searchObject->getResultTotal() === 0) {
return false;
}
......
<?php
/**
* Next/previous navigation test class.
*
* PHP version 5
*
* Copyright (C) Villanova University 2018.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category VuFind
* @package Tests
* @author Conor Sheehan <csheehan@nli.ie>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org Main Page
*/
namespace VuFindTest\Mink;
/**
* Next/previous navigation test class.
*
* @category VuFind
* @package Tests
* @author Conor Sheehan <csheehan@nli.ie>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org Main Page
*/
class NextPrevNavTest extends \VuFindTest\Unit\MinkTestCase
{
/**
* if next_prev_navigation and first_last_navigation are set to true
* and a search which returns no results is run
* when a record page is visited no next prev navigation should be shown
* and no exception should be thrown
*
* @return void
*/
public function testEmptySearchResultsCauseNoProblems()
{
$this->changeConfigs(["config" => ["Record" => ["next_prev_navigation" => true, "first_last_navigation" => true]]]);
// when a search returns no results
// make sure no errors occur when visiting a collection record after
$session = $this->getMinkSession();
$page = $session->getPage();
$session->visit($this->getVuFindUrl() . "/Search/Results?lookfor=__ReturnNoResults__&type=AllField");
$this->assertEquals($this->findCss($page, ".search-stats > h2")->getText(), "No Results!");
// collection should render as normal
$session->visit($this->getVuFindUrl() . "/Record/geo20001");
// should fail if exception is thrown
$this->assertContains("Test Publication 20001", $this->findCss($page, "div.media-body > h3[property=name]")->getText());
}
}
......@@ -43,6 +43,29 @@ use Zend\Session\Container;
*/
class ResultScrollerTest extends TestCase
{
/**
* Test next_prev_nav bug
* Expect next_prev to behave like it's disabled if the last search didn't return any results
*
* @return void
*/
public function testNextPrevNavBug()
{
$results = $this->getMockResults(0, 0, 0, true, 'sorted');
$plugin = $this->getMockResultScroller($results);
$this->assertFalse($plugin->init($results));
$expected = [
'firstRecord' => null, 'lastRecord' => null,
'previousRecord' => null, 'nextRecord' => null,
'currentPosition' => null, 'resultTotal' => null
];
$this->assertEquals($expected, $plugin->getScrollData(
$results->getMockRecordDriver('sorted20'))
);
}
/**
* Test disabled behavior
*
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment