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>.
20 use Test
::More tests
=> 2;
22 use t
::lib
::TestBuilder
;
31 use Koha
::Patron
::Categories
;
35 my $schema = Koha
::Database
->schema;
36 $schema->storage->txn_begin;
38 my $builder = t
::lib
::TestBuilder
->new;
39 my $dbh = C4
::Context
->dbh;
41 $dbh->do(q
|DELETE FROM issues
|);
43 my $branchcode = $builder->build({ source
=> 'Branch' })->{ branchcode
};
44 my $itemtype = $builder->build({ source
=> 'Itemtype' })->{ itemtype
};
47 homebranch
=> $branchcode,
48 holdingbranch
=> $branchcode,
52 my ($biblionumber1) = AddBiblio
(MARC
::Record
->new, '');
53 my $itemnumber1 = AddItem
({ barcode
=> '0101', %item_infos }, $biblionumber1);
54 my $itemnumber2 = AddItem
({ barcode
=> '0102', %item_infos }, $biblionumber1);
56 my ($biblionumber2) = AddBiblio
(MARC
::Record
->new, '');
57 my $itemnumber3 = AddItem
({ barcode
=> '0203', %item_infos }, $biblionumber2);
59 my $categorycode = $builder->build({ source
=> 'Category' })->{ categorycode
};
60 my $borrowernumber = $builder->build(
61 { source
=> 'Borrower',
62 value
=> { categorycode
=> $categorycode, branchcode
=> $branchcode }
66 my $borrower = Koha
::Patrons
->find( $borrowernumber )->unblessed;
68 # Need to mock userenv for AddIssue
69 my $module = new Test
::MockModule
('C4::Context');
70 $module->mock('userenv', sub { { branch
=> $branchcode } });
71 AddIssue
($borrower, '0101');
72 AddIssue
($borrower, '0203');
75 my $onsite_checkouts = GetPendingOnSiteCheckouts
;
76 is
( scalar @
$onsite_checkouts, 0, "No pending on-site checkouts" );
78 my $itemnumber4 = AddItem
({ barcode
=> '0104', %item_infos }, $biblionumber1);
79 AddIssue
( $borrower, '0104', undef, undef, undef, undef, { onsite_checkout
=> 1 } );
80 $onsite_checkouts = GetPendingOnSiteCheckouts
;
81 is
( scalar @
$onsite_checkouts, 1, "There is 1 pending on-site checkout" );
83 $schema->storage->txn_rollback;