|
Lines 2-8
Link Here
|
| 2 |
|
2 |
|
| 3 |
use Modern::Perl; |
3 |
use Modern::Perl; |
| 4 |
|
4 |
|
| 5 |
use Test::More tests => 4; |
5 |
use Test::More tests => 7; |
| 6 |
use MARC::Record; |
6 |
use MARC::Record; |
| 7 |
|
7 |
|
| 8 |
use C4::Branch; |
8 |
use C4::Branch; |
|
Lines 28-39
my $title = 'Silence in the library';
Link Here
|
| 28 |
$bib->append_fields( |
28 |
$bib->append_fields( |
| 29 |
MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'), |
29 |
MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'), |
| 30 |
MARC::Field->new('245', ' ', ' ', a => $title), |
30 |
MARC::Field->new('245', ' ', ' ', a => $title), |
|
|
31 |
MARC::Field->new('300', ' ', ' ', a => '2 vols.'), |
| 31 |
); |
32 |
); |
| 32 |
my ($bibnum, $bibitemnum); |
33 |
my ($bibnum, $bibitemnum); |
| 33 |
($bibnum, $title, $bibitemnum) = AddBiblio($bib, ''); |
34 |
($bibnum, $title, $bibitemnum) = AddBiblio($bib, ''); |
| 34 |
# Helper item for that biblio. |
35 |
# Helper item for that biblio. |
|
|
36 |
my @branches = GetBranchesLoop(); |
| 37 |
my $branch = $branches[0][0]{value}; |
| 35 |
diag("Creating item instance for testing."); |
38 |
diag("Creating item instance for testing."); |
| 36 |
my ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => 'CPL', holdingbranch => 'CPL' } , $bibnum); |
39 |
my ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $branch||'CPL', holdingbranch => $branch||'CPL' } , $bibnum); |
| 37 |
|
40 |
|
| 38 |
# Modify item; setting barcode. |
41 |
# Modify item; setting barcode. |
| 39 |
my $testbarcode = '97531'; |
42 |
my $testbarcode = '97531'; |
|
Lines 44-50
my %data = (
Link Here
|
| 44 |
firstname => 'my firstname', |
47 |
firstname => 'my firstname', |
| 45 |
surname => 'my surname', |
48 |
surname => 'my surname', |
| 46 |
categorycode => 'S', |
49 |
categorycode => 'S', |
| 47 |
branchcode => 'CPL', |
50 |
#TODO: Hardcoded staff category may fail? |
|
|
51 |
branchcode => $branch||'CPL', |
| 48 |
); |
52 |
); |
| 49 |
my $borrowernumber = AddMember(%data); |
53 |
my $borrowernumber = AddMember(%data); |
| 50 |
my $borrower = GetMember( borrowernumber => $borrowernumber ); |
54 |
my $borrower = GetMember( borrowernumber => $borrowernumber ); |
|
Lines 60-68
my $notes = '';
Link Here
|
| 60 |
my $checkitem = undef; |
64 |
my $checkitem = undef; |
| 61 |
my $found = undef; |
65 |
my $found = undef; |
| 62 |
|
66 |
|
| 63 |
my @branches = GetBranchesLoop(); |
|
|
| 64 |
my $branch = $branches[0][0]{value}; |
| 65 |
|
| 66 |
AddReserve($branch, $borrowernumber, $biblionumber, |
67 |
AddReserve($branch, $borrowernumber, $biblionumber, |
| 67 |
$constraint, $bibitems, $priority, $resdate, $expdate, $notes, |
68 |
$constraint, $bibitems, $priority, $resdate, $expdate, $notes, |
| 68 |
$title, $checkitem, $found); |
69 |
$title, $checkitem, $found); |
|
Lines 76-78
is($status, "Reserved", "CheckReserves Test 2");
Link Here
|
| 76 |
|
77 |
|
| 77 |
($status, $reserve, $all_reserves) = CheckReserves(undef, $barcode); |
78 |
($status, $reserve, $all_reserves) = CheckReserves(undef, $barcode); |
| 78 |
is($status, "Reserved", "CheckReserves Test 3"); |
79 |
is($status, "Reserved", "CheckReserves Test 3"); |
| 79 |
- |
80 |
|
|
|
81 |
#tests for mandatory hold notes |
| 82 |
my $shownotes=C4::Context->preference('OPACHoldNotes'); |
| 83 |
my $mandnotes=C4::Context->preference('OPACMandatoryHoldNotes'); |
| 84 |
C4::Context->set_preference('OPACHoldNotes', 1); |
| 85 |
C4::Context->set_preference('OPACMandatoryHoldNotes', '1&2'); |
| 86 |
|
| 87 |
my $record=GetMarcBiblio($bibnum); |
| 88 |
|
| 89 |
my $retval= C4::Reserves::GetMandatoryNoteReason($bibnum,$record); |
| 90 |
is($retval, 1, "Mandatory hold notes test 1"); |
| 91 |
|
| 92 |
C4::Context->set_preference('OPACMandatoryHoldNotes', '4'); |
| 93 |
$retval= C4::Reserves::GetMandatoryNoteReason($bibnum,$record); |
| 94 |
is($retval, 0, "Mandatory hold notes test 2"); |
| 95 |
|
| 96 |
C4::Context->set_preference('OPACMandatoryHoldNotes', '1&2'); |
| 97 |
C4::Context->set_preference('OPACHoldNotes', 0); |
| 98 |
$retval= C4::Reserves::GetMandatoryNoteReason($bibnum,$record); |
| 99 |
is($retval, 0, "Mandatory hold notes test 3"); |
| 100 |
|
| 101 |
#reset prefs |
| 102 |
C4::Context->set_preference('OPACHoldNotes', $shownotes); |
| 103 |
C4::Context->set_preference('OPACMandatoryHoldNotes', $mandnotes); |