|
Lines 1-10
Link Here
|
| 1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
| 2 |
|
2 |
|
|
|
3 |
# This file is part of Koha. |
| 4 |
# |
| 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. |
| 9 |
# |
| 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. |
| 14 |
# |
| 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>. |
| 17 |
|
| 3 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 4 |
|
19 |
|
| 5 |
use Test::More tests => 16; |
20 |
use Test::More tests => 16; |
| 6 |
use Test::MockModule; |
21 |
use Test::MockModule; |
| 7 |
|
22 |
|
|
|
23 |
use t::lib::TestBuilder; |
| 24 |
|
| 8 |
use C4::Biblio; |
25 |
use C4::Biblio; |
| 9 |
use C4::Items; |
26 |
use C4::Items; |
| 10 |
use C4::Members; |
27 |
use C4::Members; |
|
Lines 12-20
use C4::Circulation;
Link Here
|
| 12 |
use Koha::Libraries; |
29 |
use Koha::Libraries; |
| 13 |
use MARC::Record; |
30 |
use MARC::Record; |
| 14 |
|
31 |
|
|
|
32 |
my $schema = Koha::Database->schema; |
| 15 |
my $dbh = C4::Context->dbh; |
33 |
my $dbh = C4::Context->dbh; |
| 16 |
$dbh->{AutoCommit} = 0; |
34 |
$schema->storage->txn_begin; |
| 17 |
$dbh->{RaiseError} = 1; |
35 |
|
|
|
36 |
my $builder = t::lib::TestBuilder->new; |
| 18 |
|
37 |
|
| 19 |
$dbh->do(q|DELETE FROM issues|); |
38 |
$dbh->do(q|DELETE FROM issues|); |
| 20 |
$dbh->do(q|DELETE FROM borrowers|); |
39 |
$dbh->do(q|DELETE FROM borrowers|); |
|
Lines 23-49
$dbh->do(q|DELETE FROM branches|);
Link Here
|
| 23 |
$dbh->do(q|DELETE FROM biblio|); |
42 |
$dbh->do(q|DELETE FROM biblio|); |
| 24 |
$dbh->do(q|DELETE FROM categories|); |
43 |
$dbh->do(q|DELETE FROM categories|); |
| 25 |
|
44 |
|
| 26 |
my $branchcode = 'B'; |
45 |
my $branchcode = $builder->build( { source => 'Branch' } )->{branchcode}; |
| 27 |
Koha::Library->new( { branchcode => $branchcode, branchname => 'Branch' } )->store; |
46 |
my $categorycode = $builder->build( { source => 'Category' } )->{categorycode}; |
|
|
47 |
my $itemtype = $builder->build( { source => 'Itemtype' } )->{itemtype}; |
| 28 |
|
48 |
|
| 29 |
my $categorycode = 'C'; |
49 |
my %item_infos = ( |
| 30 |
$dbh->do( "INSERT INTO categories(categorycode) VALUES(?)", |
|
|
| 31 |
undef, $categorycode ); |
| 32 |
|
| 33 |
my %item_branch_infos = ( |
| 34 |
homebranch => $branchcode, |
50 |
homebranch => $branchcode, |
| 35 |
holdingbranch => $branchcode, |
51 |
holdingbranch => $branchcode, |
|
|
52 |
itype => $itemtype |
| 36 |
); |
53 |
); |
| 37 |
|
54 |
|
| 38 |
my ($biblionumber1) = AddBiblio( MARC::Record->new, '' ); |
55 |
my ($biblionumber1) = AddBiblio( MARC::Record->new, '' ); |
| 39 |
my $itemnumber1 = |
56 |
my $itemnumber1 = |
| 40 |
AddItem( { barcode => '0101', %item_branch_infos }, $biblionumber1 ); |
57 |
AddItem( { barcode => '0101', %item_infos }, $biblionumber1 ); |
| 41 |
my $itemnumber2 = |
58 |
my $itemnumber2 = |
| 42 |
AddItem( { barcode => '0102', %item_branch_infos }, $biblionumber1 ); |
59 |
AddItem( { barcode => '0102', %item_infos }, $biblionumber1 ); |
| 43 |
|
60 |
|
| 44 |
my ($biblionumber2) = AddBiblio( MARC::Record->new, '' ); |
61 |
my ($biblionumber2) = AddBiblio( MARC::Record->new, '' ); |
| 45 |
my $itemnumber3 = |
62 |
my $itemnumber3 = |
| 46 |
AddItem( { barcode => '0203', %item_branch_infos }, $biblionumber2 ); |
63 |
AddItem( { barcode => '0203', %item_infos }, $biblionumber2 ); |
| 47 |
|
64 |
|
| 48 |
my $borrowernumber1 = |
65 |
my $borrowernumber1 = |
| 49 |
AddMember( categorycode => $categorycode, branchcode => $branchcode ); |
66 |
AddMember( categorycode => $categorycode, branchcode => $branchcode ); |
|
Lines 92-95
$issues = C4::Members::GetAllIssues($borrowernumber2);
Link Here
|
| 92 |
is( @$issues, 1, 'GetAllIssues returns the correct number of elements' ); |
109 |
is( @$issues, 1, 'GetAllIssues returns the correct number of elements' ); |
| 93 |
is( $issues->[0]->{itemnumber}, $itemnumber3, '' ); |
110 |
is( $issues->[0]->{itemnumber}, $itemnumber3, '' ); |
| 94 |
|
111 |
|
| 95 |
$dbh->rollback(); |
112 |
$schema->storage->txn_begin; |
|
|
113 |
|
| 114 |
1; |