@@ -, +, @@ --- t/db_dependent/Reserves.t | 27 ++++++++++++++++++++++----- 1 files changed, 22 insertions(+), 5 deletions(-) --- a/t/db_dependent/Reserves.t +++ a/t/db_dependent/Reserves.t @@ -2,7 +2,7 @@ use Modern::Perl; -use Test::More tests => 17; +use Test::More tests => 20; use MARC::Record; use DateTime::Duration; @@ -43,6 +43,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, ''); @@ -76,10 +77,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); @@ -266,4 +264,23 @@ is(exists $messages->{ResFound}?1:0, 1, 'AddReturn considers future reserve with my $letter = ReserveSlip('CPL', $requesters{'CPL'}, $bibnum); ok(defined($letter), 'can successfully generate hold slip (bug 10949)'); +# Tests for mandatory hold notes (bug 9743) +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 (BZ 9743) + $dbh->rollback; --