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
=> 3;
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_sample_biblio;
54 my $item1 = $builder->build_sample_item(
56 biblionumber
=> $biblio->biblionumber,
57 library
=> $library->{branchcode
},
60 my $item2 = $builder->build_sample_item(
62 biblionumber
=> $biblio->biblionumber,
63 library
=> $library->{branchcode
},
67 my $hold1 = Koha
::Hold
->new(
69 biblionumber
=> $biblio->biblionumber,
70 itemnumber
=> $item1->itemnumber,
71 waitingdate
=> '2000-01-01',
72 borrowernumber
=> $patron->{borrowernumber
},
73 branchcode
=> $library->{branchcode
},
77 my $hold2 = Koha
::Hold
->new(
79 biblionumber
=> $biblio->biblionumber,
80 itemnumber
=> $item2->itemnumber,
81 waitingdate
=> '2000-01-01',
82 borrowernumber
=> $patron->{borrowernumber
},
83 branchcode
=> $library->{branchcode
},
87 my $letter = $builder->build(
91 module
=> 'circulation',
94 branchcode
=> $library->{branchcode
},
95 content
=> 'Hold found for <<borrowers.firstname>>: Please pick up <<biblio.title>> with barcode <<items.barcode>> at <<branches.branchcode>>.',
96 message_transport_type
=> 'email',
101 is
( ReserveSlip
(), undef, "No hold slip returned if invalid or undef borrowernumber and/or biblionumber" );
103 branchcode
=> $library->{branchcode
},
104 reserve_id
=> $hold1->reserve_id,
106 'HOLD_SLIP', "Get a hold slip from library, patron and biblio" );
109 branchcode
=> $library->{branchcode
},
110 reserve_id
=> $hold1->reserve_id,
112 sprintf( "Hold found for %s: Please pick up %s with barcode %s at %s.", $patron->{firstname
}, $biblio->title, $item1->barcode, $library->{branchcode
}),"Hold slip contains correctly parsed content");
114 $schema->storage->txn_rollback;