From 0e9a8f89e03ffdea9241000beec0453faea2ec7b Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Wed, 6 Mar 2013 14:58:29 +0100 Subject: [PATCH] Bug 9743: Unit test for mandatory hold notes Content-Type: text/plain; charset=utf-8 Note: I remove the lines dealing testing existence of CPL branch. I have submitted a patch under report 9761 dealing with that situation. Test plan: Export PERL5LIB and KOHA_CONF to your test database. Run t/db_dependent/Reserves.t. --- t/db_dependent/Reserves.t | 29 ++++++++++++++++++++++++----- 1 files changed, 24 insertions(+), 5 deletions(-) diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t index f511c41..444ef06 100755 --- a/t/db_dependent/Reserves.t +++ b/t/db_dependent/Reserves.t @@ -2,7 +2,7 @@ use Modern::Perl; -use Test::More tests => 8; +use Test::More tests => 11; use MARC::Record; use C4::Branch; @@ -29,6 +29,7 @@ my $title = 'Silence in the library'; $bib->append_fields( MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'), MARC::Field->new('245', ' ', ' ', a => $title), + MARC::Field->new('300', ' ', ' ', a => '2 vols.'), ); my ($bibnum, $bibitemnum); ($bibnum, $title, $bibitemnum) = AddBiblio($bib, ''); @@ -61,10 +62,7 @@ my $notes = ''; my $checkitem = undef; my $found = undef; -my @branches = GetBranchesLoop(); -my $branch = $branches[0][0]{value}; - -AddReserve($branch, $borrowernumber, $biblionumber, +AddReserve('CPL', $borrowernumber, $biblionumber, $constraint, $bibitems, $priority, $resdate, $expdate, $notes, $title, $checkitem, $found); @@ -199,3 +197,24 @@ is( $messages->{ResFound}->{borrowernumber}, is( $messages->{ResFound}->{borrowernumber}, $requesters{'RPL'}, 'for generous library, its items fill first hold request in line (bug 10272)'); + +#tests for mandatory hold notes +C4::Context->set_preference('OPACHoldNotes', 1); +C4::Context->set_preference('OPACMandatoryHoldNotes', '1&2'); + +my $record=GetMarcBiblio($bibnum); + +my $retval= C4::Reserves::GetMandatoryNoteReason($bibnum,$record); +is($retval, 1, "Mandatory hold notes test 1"); + +C4::Context->set_preference('OPACMandatoryHoldNotes', '4'); +$retval= C4::Reserves::GetMandatoryNoteReason($bibnum,$record); +is($retval, 0, "Mandatory hold notes test 2"); + +C4::Context->set_preference('OPACMandatoryHoldNotes', '1&2'); +C4::Context->set_preference('OPACHoldNotes', 0); +$retval= C4::Reserves::GetMandatoryNoteReason($bibnum,$record); +is($retval, 0, "Mandatory hold notes test 3"); +#end of mandatory hold notes tests + +$dbh->rollback; -- 1.7.7.6