View | Details | Raw Unified | Return to bug 17715
Collapse All | Expand All

(-)a/t/db_dependent/Holds/RevertWaitingStatus.t (-10 / +29 lines)
Lines 1-5 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 t::lib::Mocks;
20
use t::lib::Mocks;
Lines 25-39 $dbh->{RaiseError} = 1; Link Here
25
$dbh->do("DELETE FROM reserves");
40
$dbh->do("DELETE FROM reserves");
26
$dbh->do("DELETE FROM old_reserves");
41
$dbh->do("DELETE FROM old_reserves");
27
42
28
my $library = $builder->build({
43
my $branchcode = $builder->build( { source => 'Branch' } )->{branchcode};
29
    source => 'Branch',
44
my $itemtype = $builder->build(
30
});
45
    { source => 'Itemtype', value => { notforloan => undef } } )->{itemtype};
31
46
32
local $SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /redefined/ };
47
local $SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /redefined/ };
33
*C4::Context::userenv = \&Mock_userenv;
48
*C4::Context::userenv = \&Mock_userenv;
34
49
35
sub Mock_userenv {
50
sub Mock_userenv {
36
    my $userenv = { flags => 1, id => '1', branch => $library->{branchcode} };
51
    my $userenv = { flags => 1, id => '1', branch => $branchcode };
37
    return $userenv;
52
    return $userenv;
38
}
53
}
39
54
Lines 45-52 my ( $bibnum, $title, $bibitemnum ) = create_helper_biblio(); Link Here
45
# Create an item
60
# Create an item
46
my $item_barcode = 'my_barcode';
61
my $item_barcode = 'my_barcode';
47
my ( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem(
62
my ( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem(
48
    { homebranch => $library->{branchcode}, holdingbranch => $library->{branchcode}, barcode => $item_barcode },
63
    {   homebranch    => $branchcode,
49
    $bibnum );
64
        holdingbranch => $branchcode,
65
        barcode       => $item_barcode,
66
        itype         => $itemtype
67
    },
68
    $bibnum
69
);
50
70
51
# Create some borrowers
71
# Create some borrowers
52
my @borrowernumbers;
72
my @borrowernumbers;
Lines 55-69 foreach my $i ( 1 .. $borrowers_count ) { Link Here
55
        firstname    => 'my firstname',
75
        firstname    => 'my firstname',
56
        surname      => 'my surname ' . $i,
76
        surname      => 'my surname ' . $i,
57
        categorycode => 'S',
77
        categorycode => 'S',
58
        branchcode   => $library->{branchcode},
78
        branchcode   => $branchcode,
59
    );
79
    );
60
    push @borrowernumbers, $borrowernumber;
80
    push @borrowernumbers, $borrowernumber;
61
}
81
}
62
82
63
my $biblionumber = $bibnum;
83
my $biblionumber = $bibnum;
64
84
65
my $branchcode = Koha::Libraries->search->next->branchcode;
66
67
# Create five item level holds
85
# Create five item level holds
68
foreach my $borrowernumber (@borrowernumbers) {
86
foreach my $borrowernumber (@borrowernumbers) {
69
    AddReserve(
87
    AddReserve(
Lines 91-96 ok( scalar @$priorities == 2, 'Only 2 holds remain in the reserves table' ); Link Here
91
ok( $priorities->[0]->[0] == 1, 'First hold has a priority of 1' );
109
ok( $priorities->[0]->[0] == 1, 'First hold has a priority of 1' );
92
ok( $priorities->[1]->[0] == 2, 'Second hold has a priority of 2' );
110
ok( $priorities->[1]->[0] == 2, 'Second hold has a priority of 2' );
93
111
112
$schema->storage->txn_rollback;
113
94
# Helper method to set up a Biblio.
114
# Helper method to set up a Biblio.
95
sub create_helper_biblio {
115
sub create_helper_biblio {
96
    my $bib   = MARC::Record->new();
116
    my $bib   = MARC::Record->new();
97
- 

Return to bug 17715