|
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 |
|