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

(-)a/t/db_dependent/Holds/HoldFulfillmentPolicy.t (-3 / +20 lines)
Lines 4-12 use Modern::Perl; Link Here
4
4
5
use C4::Context;
5
use C4::Context;
6
6
7
use Test::More tests => 10;
7
use Test::More tests => 14;
8
8
9
use t::lib::TestBuilder;
9
use t::lib::TestBuilder;
10
use t::lib::Mocks;
10
use Koha::Holds;
11
use Koha::Holds;
11
12
12
BEGIN {
13
BEGIN {
Lines 38-44 my $borrower = $builder->build({ Link Here
38
        branchcode => $library1->{branchcode},
39
        branchcode => $library1->{branchcode},
39
    }
40
    }
40
});
41
});
41
42
# Test hold_fulfillment_policy
42
# Test hold_fulfillment_policy
43
my $borrowernumber = $borrower->{borrowernumber};
43
my $borrowernumber = $borrower->{borrowernumber};
44
my $library_A = $library1->{branchcode};
44
my $library_A = $library1->{branchcode};
Lines 76-81 my $itemnumber = Link Here
76
$dbh->do("DELETE FROM default_circ_rules");
76
$dbh->do("DELETE FROM default_circ_rules");
77
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'homebranch' )");
77
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'homebranch' )");
78
78
79
t::lib::Mocks::mock_preference('TriggerForbiddenHolds', 0);
79
# Home branch matches pickup branch
80
# Home branch matches pickup branch
80
my $reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
81
my $reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
81
my ( $status ) = CheckReserves($itemnumber);
82
my ( $status ) = CheckReserves($itemnumber);
Lines 86-97 Koha::Holds->find( $reserve_id )->cancel; Link Here
86
$reserve_id = AddReserve( $library_B, $borrowernumber, $biblionumber, '', 1 );
87
$reserve_id = AddReserve( $library_B, $borrowernumber, $biblionumber, '', 1 );
87
( $status ) = CheckReserves($itemnumber);
88
( $status ) = CheckReserves($itemnumber);
88
is($status, q{}, "Hold where pickup ne home, pickup eq home not targeted" );
89
is($status, q{}, "Hold where pickup ne home, pickup eq home not targeted" );
90
t::lib::Mocks::mock_preference('TriggerForbiddenHolds', 1);
91
( $status ) = CheckReserves($itemnumber);
92
is($status, 'Reserved', "Hold where pickup ne home, pickup eq home targeted when TriggerForbiddenHolds set to yes" );
93
t::lib::Mocks::mock_preference('TriggerForbiddenHolds', 0);
89
Koha::Holds->find( $reserve_id )->cancel;
94
Koha::Holds->find( $reserve_id )->cancel;
90
95
91
# Neither branch matches pickup branch
96
# Neither branch matches pickup branch
92
$reserve_id = AddReserve( $library_C, $borrowernumber, $biblionumber, '', 1 );
97
$reserve_id = AddReserve( $library_C, $borrowernumber, $biblionumber, '', 1 );
93
( $status ) = CheckReserves($itemnumber);
98
( $status ) = CheckReserves($itemnumber);
94
is( $status, q{}, "Hold where pickup ne home, pickup ne holding not targeted" );
99
is( $status, q{}, "Hold where pickup ne home, pickup ne holding not targeted" );
100
t::lib::Mocks::mock_preference('TriggerForbiddenHolds', 1);
101
( $status ) = CheckReserves($itemnumber);
102
is( $status, 'Reserved', "Hold where pickup ne home, pickup ne holding targeted when TriggerForbiddenHolds set to yes" );
103
t::lib::Mocks::mock_preference('TriggerForbiddenHolds', 0);
95
Koha::Holds->find( $reserve_id )->cancel;
104
Koha::Holds->find( $reserve_id )->cancel;
96
105
97
# With hold_fulfillment_policy = holdingbranch, hold should only be picked up if pickup branch = holdingbranch
106
# With hold_fulfillment_policy = holdingbranch, hold should only be picked up if pickup branch = holdingbranch
Lines 102-107 $dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy Link Here
102
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
111
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
103
( $status ) = CheckReserves($itemnumber);
112
( $status ) = CheckReserves($itemnumber);
104
is( $status, q{}, "Hold where pickup eq home, pickup ne holding not targeted" );
113
is( $status, q{}, "Hold where pickup eq home, pickup ne holding not targeted" );
114
t::lib::Mocks::mock_preference('TriggerForbiddenHolds', 1);
115
( $status ) = CheckReserves($itemnumber);
116
is( $status, 'Reserved', "Hold where pickup eq home, pickup ne holding targeted when TriggerForbiddenHolds set to yes" );
117
t::lib::Mocks::mock_preference('TriggerForbiddenHolds', 0);
105
Koha::Holds->find( $reserve_id )->cancel;
118
Koha::Holds->find( $reserve_id )->cancel;
106
119
107
# Holding branch matches pickup branch
120
# Holding branch matches pickup branch
Lines 114-122 Koha::Holds->find( $reserve_id )->cancel; Link Here
114
$reserve_id = AddReserve( $library_C, $borrowernumber, $biblionumber, '', 1 );
127
$reserve_id = AddReserve( $library_C, $borrowernumber, $biblionumber, '', 1 );
115
( $status ) = CheckReserves($itemnumber);
128
( $status ) = CheckReserves($itemnumber);
116
is( $status, q{}, "Hold where pickup ne home, pickup ne holding not targeted" );
129
is( $status, q{}, "Hold where pickup ne home, pickup ne holding not targeted" );
130
t::lib::Mocks::mock_preference('TriggerForbiddenHolds', 1);
131
( $status ) = CheckReserves($itemnumber);
132
is( $status, 'Reserved', "Hold where pickup ne home, pickup ne holding targeted when TriggerForbiddenHolds set to yes" );
133
t::lib::Mocks::mock_preference('TriggerForbiddenHolds', 0);
117
Koha::Holds->find( $reserve_id )->cancel;
134
Koha::Holds->find( $reserve_id )->cancel;
118
135
119
# With hold_fulfillment_policy = any, hold should be pikcup up reguardless of matching home or holding branch
136
# With hold_fulfillment_policy = any, hold should be pickup up reguardless of matching home or holding branch
120
$dbh->do("DELETE FROM default_circ_rules");
137
$dbh->do("DELETE FROM default_circ_rules");
121
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'any' )");
138
$dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'any' )");
122
139
(-)a/t/db_dependent/Reserves.t (-2 / +8 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 57;
20
use Test::More tests => 58;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Warn;
22
use Test::Warn;
23
23
Lines 301-310 my $messages; Link Here
301
# Return the CPL item at FPL.  The hold that should be triggered is
301
# Return the CPL item at FPL.  The hold that should be triggered is
302
# the one placed by the CPL patron, as the other two patron's hold
302
# the one placed by the CPL patron, as the other two patron's hold
303
# requests cannot be filled by that item per policy.
303
# requests cannot be filled by that item per policy.
304
t::lib::Mocks::mock_preference('TriggerForbiddenHolds', 0);
304
(undef, $messages, undef, undef) = AddReturn('bug10272_CPL', $branch_2);
305
(undef, $messages, undef, undef) = AddReturn('bug10272_CPL', $branch_2);
305
is( $messages->{ResFound}->{borrowernumber},
306
is( $messages->{ResFound}->{borrowernumber},
306
    $requesters{$branch_1},
307
    $requesters{$branch_1},
307
    'restrictive library\'s items only fill requests by own patrons (bug 10272)');
308
    'restrictive library\'s items only fill requests by own patrons (bug 10272)');
309
t::lib::Mocks::mock_preference('TriggerForbiddenHolds', 1);
310
(undef, $messages, undef, undef) = AddReturn('bug10272_CPL', $branch_2);
311
is( $messages->{ResFound}->{borrowernumber},
312
    $requesters{$branch_3},
313
    'restrictive library\'s items fill requests when TriggerForbiddenHolds set to yes');
314
t::lib::Mocks::mock_preference('TriggerForbiddenHolds', 0);
308
315
309
# Return the FPL item at FPL.  The hold that should be triggered is
316
# Return the FPL item at FPL.  The hold that should be triggered is
310
# the one placed by the RPL patron, as that patron is first in line
317
# the one placed by the RPL patron, as that patron is first in line
311
- 

Return to bug 20955