3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
23 use Koha::Illrequests;
26 use t::lib::TestBuilder;
30 use Test::More tests => 6;
32 my $schema = Koha::Database->new->schema;
33 my $builder = t::lib::TestBuilder->new;
34 use_ok('Koha::Illbatch');
35 use_ok('Koha::Illbatches');
37 $schema->storage->txn_begin;
40 my $patron = $builder->build( { source => 'Borrower' } );
43 my $librarian = $builder->build(
46 value => { firstname => "Grogu" }
51 my $branch = $builder->build( { source => 'Branch' } );
54 my $illbatch = $builder->build_object(
56 class => 'Koha::Illbatches',
58 name => "My test batch",
60 patron_id => $librarian->{borrowernumber},
61 library_id => $branch->{branchcode}
66 # Create an ILL request in the batch
67 my $illrq = $builder->build(
69 source => 'Illrequest',
71 borrowernumber => $patron->{borrowernumber},
72 batch_id => $illbatch->id
76 my $illrq_obj = Koha::Illrequests->find( $illrq->{illrequest_id} );
79 my $batch_patron = $illbatch->patron;
80 isa_ok( $batch_patron, 'Koha::Patron' );
81 is( $batch_patron->firstname, "Grogu", "patron returns correctly" );
84 my $batch_branch = $illbatch->library;
85 isa_ok( $batch_branch, 'Koha::Library' );
86 is( $batch_branch->branchcode, $branch->{branchcode}, "branch returns correctly" );
89 $schema->storage->txn_rollback;