3 # Copyright 2016 Oslo Public Library
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use Test::More tests => 5;
23 use t::lib::TestBuilder;
25 use C4::Reserves qw( ReserveSlip );
29 my $schema = Koha::Database->new->schema;
30 $schema->storage->txn_begin;
32 my $dbh = C4::Context->dbh;
33 $dbh->do(q|DELETE FROM letter|);
34 $dbh->do(q|DELETE FROM reserves|);
36 my $builder = t::lib::TestBuilder->new();
37 my $library = $builder->build(
43 my $patron = $builder->build(
47 branchcode => $library->{branchcode},
53 my $biblio = $builder->build(
62 my $item1 = $builder->build(
66 biblionumber => $biblio->{biblionumber},
67 homebranch => $library->{branchcode},
68 holdingbranch => $library->{branchcode},
73 my $item2 = $builder->build(
77 biblionumber => $biblio->{biblionumber},
78 homebranch => $library->{branchcode},
79 holdingbranch => $library->{branchcode},
84 my $hold1 = Koha::Hold->new(
86 biblionumber => $biblio->{biblionumber},
87 itemnumber => $item1->{itemnumber},
88 waitingdate => '2000-01-01',
89 borrowernumber => $patron->{borrowernumber},
90 branchcode => $library->{branchcode},
94 my $hold2 = Koha::Hold->new(
96 biblionumber => $biblio->{biblionumber},
97 itemnumber => $item2->{itemnumber},
98 waitingdate => '2000-01-01',
99 borrowernumber => $patron->{borrowernumber},
100 branchcode => $library->{branchcode},
104 my $letter = $builder->build(
108 module => 'circulation',
111 branchcode => $library->{branchcode},
112 content => 'Hold found for <<borrowers.firstname>>: Please pick up <<biblio.title>> with barcode <<items.barcode>> at <<branches.branchcode>>.',
113 message_transport_type => 'email',
118 is ( ReserveSlip(), undef, "No hold slip returned if invalid or undef borrowernumber and/or biblionumber" );
120 branchcode => $library->{branchcode},
121 borrowernumber => $patron->{borrowernumber},
122 biblionumber => $biblio->{biblionumber},
124 'HOLD_SLIP', "Get a hold slip from library, patron and biblio" );
127 branchcode => $library->{branchcode},
128 borrowernumber => $patron->{borrowernumber},
129 biblionumber => $biblio->{biblionumber},
131 "Hold found for $patron->{firstname}: Please pick up $biblio->{title} with barcode $item1->{barcode} at $library->{branchcode}.", "Hold slip contains correctly parsed content");
135 branchcode => $library->{branchcode},
136 borrowernumber => $patron->{borrowernumber},
137 biblionumber => $biblio->{biblionumber},
140 branchcode => $library->{branchcode},
141 borrowernumber => $patron->{borrowernumber},
142 biblionumber => $biblio->{biblionumber},
143 itemnumber => $item1->{itemnumber},
144 barcode => $item1->{barcode},
146 "No item as param generate hold slip from first item in reserves");
150 branchcode => $library->{branchcode},
151 borrowernumber => $patron->{borrowernumber},
152 biblionumber => $biblio->{biblionumber},
155 branchcode => $library->{branchcode},
156 borrowernumber => $patron->{borrowernumber},
157 biblionumber => $biblio->{biblionumber},
158 itemnumber => $item2->{itemnumber},
159 barcode => $item2->{barcode},
161 "Item and/or barcode as params return correct pickup item in hold slip");
163 $schema->storage->txn_rollback;