From 782a3d70af521f7d612d0266625480e6759c369e Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 30 Jun 2014 14:55:04 -0300 Subject: [PATCH] Bug 12419: (QA followup) regression tests Changes to searchResults deserve unit tests. Edit: minor tweaks: - Remove warning in line 702 - Modernize - License added - "This file is a stub" removed Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/Search.t | 56 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/t/db_dependent/Search.t b/t/db_dependent/Search.t index 46d63f4..b132e07 100644 --- a/t/db_dependent/Search.t +++ b/t/db_dependent/Search.t @@ -1,14 +1,28 @@ #!/usr/bin/perl + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. # -# This Koha test module is a stub! -# Add more tests here!!! +# Koha 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 Koha; if not, see . + +use Modern::Perl; -use strict; -use warnings; use utf8; use YAML; +use Data::Printer; +use C4::Items; use C4::Debug; require C4::Context; @@ -83,6 +97,9 @@ our $QueryWeightFields = 0; our $QueryFuzzy = 0; our $QueryRemoveStopwords = 0; our $UseQueryParser = 0; +our $DefaultClassificationSource = 'z'; +our $CataloguingLog = 0; +our $dateformat = 'metric'; our $marcflavour = 'MARC21'; our $contextmodule = new Test::MockModule('C4::Context'); $contextmodule->mock('_new_dbh', sub { @@ -117,6 +134,12 @@ $contextmodule->mock('preference', sub { return '--'; } elsif ($pref eq 'DisplayLibraryFacets') { return 'holding'; + } elsif ($pref eq 'DefaultClassificationSource') { + return $DefaultClassificationSource; + } elsif ($pref eq 'dateformat') { + return $dateformat; + } elsif ($pref eq 'CataloguingLog') { + return $CataloguingLog; } else { warn "The syspref $pref was requested but I don't know what to say; this indicates that the test requires updating" unless $pref =~ m/(XSLT|item|branch|holding|image)/i; @@ -833,6 +856,27 @@ if ( $indexing_mode eq 'dom' ) { is($newresults[0]->{biblionumber}, '300', 'Over-large bib record has the correct biblionumber (bug 11096)'); like($newresults[0]->{notes}, qr/This is large note #550/, 'Able to render the notes field for over-large bib record (bug 11096)'); + # notforloancount should be returned as part of searchResults output + ok( defined $newresults[0]->{notforloancount}, + '\'notforloancount\' defined in searchResults output (Bug 12419)'); + is( $newresults[0]->{notforloancount}, 0, + '\'notforloancount\' == 0 if no items attached (Bug 12419)'); + # Add an item to the biblio, with notforloan=1 + my ($item1_bibnum, $item1_bibitemnum, $item1_itemnumber) = AddItem( + { homebranch => 'CPL', + holdingbranch => 'CPL', + dateaccessioned => '2014-06-18', + notforloan => 1 }, + $newresults[0]->{ biblionumber } + ); + # Call search results again + @newresults = searchResults('opac', $query_desc, + $results_hashref->{'biblioserver'}->{'hits'}, 10, 0, 0, + $results_hashref->{'biblioserver'}->{"RECORDS"}); + # We should have notforloan + is( $newresults[0]->{notforloancount}, 1, + '\'notforloancount\' == 1 (Bug 12419)'); + # verify that we don't attempt to sort if no results were returned # because of a query error warning_like {( undef, $results_hashref, $facets_loop ) = @@ -914,12 +958,12 @@ sub run_unimarc_search_tests { } subtest 'MARC21 + GRS-1' => sub { - plan tests => 104; + plan tests => 105; run_marc21_search_tests('grs1'); }; subtest 'MARC21 + DOM' => sub { - plan tests => 104; + plan tests => 105; run_marc21_search_tests('dom'); }; -- 1.9.1