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

(-)a/C4/Reserves.pm (-2 / +3 lines)
Lines 2113-2119 sub MergeHolds { Link Here
2113
2113
2114
=head2 RevertWaitingStatus
2114
=head2 RevertWaitingStatus
2115
2115
2116
  $success = RevertWaitingStatus({ itemnumber => $itemnumber });
2116
  RevertWaitingStatus({ itemnumber => $itemnumber });
2117
2117
2118
  Reverts a 'waiting' hold back to a regular hold with a priority of 1.
2118
  Reverts a 'waiting' hold back to a regular hold with a priority of 1.
2119
2119
Lines 2168-2174 sub RevertWaitingStatus { Link Here
2168
      reserve_id = ?
2168
      reserve_id = ?
2169
    ";
2169
    ";
2170
    $sth = $dbh->prepare( $query );
2170
    $sth = $dbh->prepare( $query );
2171
    return $sth->execute( $reserve->{'reserve_id'} );
2171
    $sth->execute( $reserve->{'reserve_id'} );
2172
    _FixPriority( { biblionumber => $reserve->{biblionumber} } );
2172
}
2173
}
2173
2174
2174
=head2 GetReserveId
2175
=head2 GetReserveId
(-)a/t/db_dependent/Holds_12086.t (-1 / +99 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
5
use t::lib::Mocks;
6
use C4::Context;
7
use C4::Branch;
8
9
use Test::More tests => 3;
10
use MARC::Record;
11
use C4::Biblio;
12
use C4::Items;
13
use C4::Members;
14
use C4::Reserves;
15
16
BEGIN {
17
    use FindBin;
18
    use lib $FindBin::Bin;
19
}
20
21
my $dbh = C4::Context->dbh;
22
23
# Start transaction
24
$dbh->{AutoCommit} = 0;
25
$dbh->{RaiseError} = 1;
26
27
$dbh->do("TRUNCATE TABLE reserves");
28
29
*C4::Context::userenv = \&Mock_userenv;
30
sub Mock_userenv {
31
    my $userenv = { flags => 1, id => '1', branch => 'CPL' };
32
    return $userenv;
33
}
34
35
my $borrowers_count = 3;
36
37
# Setup Test------------------------
38
# Helper biblio.
39
diag("Creating biblio instance for testing.");
40
my ($bibnum, $title, $bibitemnum) = create_helper_biblio();
41
42
# Helper item for that biblio.
43
diag("Creating item instance for testing.");
44
my $item_barcode = '99999999999999999999';
45
my ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => 'CPL', holdingbranch => 'CPL', barcode => $item_barcode } , $bibnum);
46
47
# Create some borrowers
48
my @borrowernumbers;
49
foreach (1..$borrowers_count) {
50
    my $borrowernumber = AddMember(
51
        firstname =>  'my firstname',
52
        surname => 'my surname ' . $_,
53
        categorycode => 'S',
54
        branchcode => 'CPL',
55
    );
56
    push @borrowernumbers, $borrowernumber;
57
}
58
59
my $biblionumber = $bibnum;
60
61
my @branches = GetBranchesLoop();
62
my $branch = $branches[0][0]{value};
63
64
# Create five item level holds
65
foreach my $borrowernumber ( @borrowernumbers ) {
66
    AddReserve(
67
        $branch,
68
        $borrowernumber,
69
        $biblionumber,
70
        my $constraint = 'a',
71
        my $bibitems = q{},
72
        my $priority,
73
        my $resdate,
74
        my $expdate,
75
        my $notes = q{},
76
        $title,
77
        my $checkitem,
78
        my $found,
79
    );
80
}
81
82
ModReserveAffect( $itemnumber, $borrowernumbers[0] );
83
C4::Circulation::AddIssue( GetMember( borrowernumber => $borrowernumbers[1] ), $item_barcode, my $datedue, my $cancelreserve = 'revert' );
84
85
my $priorities = $dbh->selectall_arrayref("SELECT priority FROM reserves ORDER BY priority ASC");
86
ok( scalar @$priorities == 2, 'Only 2 holds remain in the reserves table' );
87
ok( $priorities->[0]->[0] == 1, 'First hold has a priority of 1' );
88
ok( $priorities->[1]->[0] == 2, 'Second hold has a priority of 2' );
89
90
# Helper method to set up a Biblio.
91
sub create_helper_biblio {
92
    my $bib = MARC::Record->new();
93
    my $title = 'Silence in the library';
94
    $bib->append_fields(
95
        MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'),
96
        MARC::Field->new('245', ' ', ' ', a => $title),
97
    );
98
    return ($bibnum, $title, $bibitemnum) = AddBiblio($bib, '');
99
}

Return to bug 12086