Lines 1-25
Link Here
|
1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
2 |
|
2 |
|
3 |
use strict; |
3 |
use Modern::Perl; |
4 |
use warnings; |
|
|
5 |
use C4::Branch; |
6 |
|
4 |
|
7 |
use Test::More tests => 4; |
5 |
use Test::More tests => 4; |
8 |
use MARC::Record; |
6 |
use MARC::Record; |
|
|
7 |
|
8 |
use C4::Branch; |
9 |
use C4::Biblio; |
9 |
use C4::Biblio; |
10 |
use C4::Items; |
10 |
use C4::Items; |
|
|
11 |
use C4::Members; |
11 |
|
12 |
|
12 |
BEGIN { |
13 |
BEGIN { |
13 |
use FindBin; |
14 |
use_ok('C4::Reserves'); |
14 |
use lib $FindBin::Bin; |
|
|
15 |
use_ok('C4::Reserves'); |
16 |
} |
15 |
} |
17 |
|
16 |
|
18 |
# Setup Test------------------------ |
17 |
# Setup Test------------------------ |
19 |
# Helper biblio. |
18 |
# Helper biblio. |
20 |
diag("\nCreating biblio instance for testing."); |
19 |
diag("\nCreating biblio instance for testing."); |
21 |
my ($bibnum, $title, $bibitemnum) = create_helper_biblio(); |
20 |
my $bib = MARC::Record->new(); |
22 |
|
21 |
my $title = 'Silence in the library'; |
|
|
22 |
$bib->append_fields( |
23 |
MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'), |
24 |
MARC::Field->new('245', ' ', ' ', a => $title), |
25 |
); |
26 |
my ($bibnum, $bibitemnum); |
27 |
($bibnum, $title, $bibitemnum) = AddBiblio($bib, ''); |
23 |
# Helper item for that biblio. |
28 |
# Helper item for that biblio. |
24 |
diag("Creating item instance for testing."); |
29 |
diag("Creating item instance for testing."); |
25 |
my ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => 'CPL', holdingbranch => 'CPL' } , $bibnum); |
30 |
my ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => 'CPL', holdingbranch => 'CPL' } , $bibnum); |
Lines 28-43
my ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => 'CPL'
Link Here
|
28 |
my $testbarcode = '97531'; |
33 |
my $testbarcode = '97531'; |
29 |
ModItem({ barcode => $testbarcode }, $bibnum, $itemnumber); |
34 |
ModItem({ barcode => $testbarcode }, $bibnum, $itemnumber); |
30 |
|
35 |
|
31 |
# Get a borrower |
36 |
# Create a borrower |
32 |
my $dbh = C4::Context->dbh; |
37 |
my %data = ( |
33 |
my $query = qq/SELECT borrowernumber |
38 |
cardnumber => 'CARDNUMBER42', |
34 |
FROM borrowers |
39 |
firstname => 'my firstname', |
35 |
LIMIT 1/; |
40 |
surname => 'my surname', |
36 |
my $sth = $dbh->prepare($query); |
41 |
categorycode => 'S', |
37 |
$sth->execute; |
42 |
branchcode => 'CPL', |
38 |
my $borrower = $sth->fetchrow_hashref; |
43 |
); |
39 |
|
44 |
my $borrowernumber = AddMember(%data); |
40 |
my $borrowernumber = $borrower->{'borrowernumber'}; |
45 |
my $borrower = GetMember( borrowernumber => $borrowernumber ); |
41 |
my $biblionumber = $bibnum; |
46 |
my $biblionumber = $bibnum; |
42 |
my $barcode = $testbarcode; |
47 |
my $barcode = $testbarcode; |
43 |
|
48 |
|
Lines 56-88
my $branch = $branches[0][0]{value};
Link Here
|
56 |
AddReserve($branch, $borrowernumber, $biblionumber, |
61 |
AddReserve($branch, $borrowernumber, $biblionumber, |
57 |
$constraint, $bibitems, $priority, $resdate, $expdate, $notes, |
62 |
$constraint, $bibitems, $priority, $resdate, $expdate, $notes, |
58 |
$title, $checkitem, $found); |
63 |
$title, $checkitem, $found); |
59 |
|
64 |
|
60 |
my ($status, $reserve, $all_reserves) = CheckReserves($itemnumber, $barcode); |
65 |
my ($status, $reserve, $all_reserves) = CheckReserves($itemnumber, $barcode); |
61 |
ok($status eq "Reserved", "CheckReserves Test 1"); |
66 |
|
|
|
67 |
is($status, "Reserved", "CheckReserves Test 1"); |
62 |
|
68 |
|
63 |
($status, $reserve, $all_reserves) = CheckReserves($itemnumber); |
69 |
($status, $reserve, $all_reserves) = CheckReserves($itemnumber); |
64 |
ok($status eq "Reserved", "CheckReserves Test 2"); |
70 |
is($status, "Reserved", "CheckReserves Test 2"); |
65 |
|
71 |
|
66 |
($status, $reserve, $all_reserves) = CheckReserves(undef, $barcode); |
72 |
($status, $reserve, $all_reserves) = CheckReserves(undef, $barcode); |
67 |
ok($status eq "Reserved", "CheckReserves Test 3"); |
73 |
is($status, "Reserved", "CheckReserves Test 3"); |
68 |
|
74 |
|
69 |
|
75 |
|
70 |
# Teardown Test--------------------- |
76 |
# Teardown Test--------------------- |
71 |
# Delete item. |
77 |
# Delete item. |
72 |
diag("Deleting item testing instance."); |
78 |
diag("Deleting item testing instance."); |
|
|
79 |
my $dbh = C4::Context->dbh; |
73 |
DelItem($dbh, $bibnum, $itemnumber); |
80 |
DelItem($dbh, $bibnum, $itemnumber); |
74 |
|
81 |
|
75 |
# Delete helper Biblio. |
82 |
# Delete helper Biblio. |
76 |
diag("Deleting biblio testing instance."); |
83 |
diag("Deleting biblio testing instance."); |
77 |
DelBiblio($bibnum); |
84 |
DelBiblio($bibnum); |
78 |
|
85 |
|
79 |
# Helper method to set up a Biblio. |
86 |
# Delete borrower |
80 |
sub create_helper_biblio { |
87 |
diag("Deleting borrower."); |
81 |
my $bib = MARC::Record->new(); |
88 |
DelMember($borrowernumber); |
82 |
my $title = 'Silence in the library'; |
|
|
83 |
$bib->append_fields( |
84 |
MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'), |
85 |
MARC::Field->new('245', ' ', ' ', a => $title), |
86 |
); |
87 |
return ($bibnum, $title, $bibitemnum) = AddBiblio($bib, ''); |
88 |
} |
89 |
- |
|
|