Lines 125-132
AddReturn( $item1->{barcode} );
Link Here
|
125 |
|
125 |
|
126 |
my $hold_allowed_from_home_library = 1; |
126 |
my $hold_allowed_from_home_library = 1; |
127 |
my $hold_allowed_from_any_libraries = 2; |
127 |
my $hold_allowed_from_any_libraries = 2; |
128 |
my $sth_delete_rules = $dbh->prepare(q|DELETE FROM default_circ_rules|); |
|
|
129 |
my $sth_insert_rule = $dbh->prepare(q|INSERT INTO default_circ_rules(singleton, holdallowed, hold_fulfillment_policy, returnbranch) VALUES ('singleton', ?, 'any', 'homebranch');|); |
130 |
|
128 |
|
131 |
subtest 'Item is available at a different library' => sub { |
129 |
subtest 'Item is available at a different library' => sub { |
132 |
plan tests => 4; |
130 |
plan tests => 4; |
Lines 142-149
AddReturn( $item1->{barcode} );
Link Here
|
142 |
#FIXME: ReservesControlBranch is not checked in these subs we are testing |
140 |
#FIXME: ReservesControlBranch is not checked in these subs we are testing |
143 |
|
141 |
|
144 |
{ |
142 |
{ |
145 |
$sth_delete_rules->execute; |
143 |
set_holdallowed_rule( $hold_allowed_from_home_library ); |
146 |
$sth_insert_rule->execute( $hold_allowed_from_home_library ); |
|
|
147 |
|
144 |
|
148 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
145 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
149 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
146 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
Lines 155-162
AddReturn( $item1->{barcode} );
Link Here
|
155 |
} |
152 |
} |
156 |
|
153 |
|
157 |
{ |
154 |
{ |
158 |
$sth_delete_rules->execute; |
155 |
set_holdallowed_rule( $hold_allowed_from_any_libraries ); |
159 |
$sth_insert_rule->execute( $hold_allowed_from_any_libraries ); |
|
|
160 |
|
156 |
|
161 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
157 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
162 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
158 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
Lines 182-189
AddReturn( $item1->{barcode} );
Link Here
|
182 |
#ReservesControlBranch is not checked in these subs we are testing? |
178 |
#ReservesControlBranch is not checked in these subs we are testing? |
183 |
|
179 |
|
184 |
{ |
180 |
{ |
185 |
$sth_delete_rules->execute; |
181 |
set_holdallowed_rule( $hold_allowed_from_home_library ); |
186 |
$sth_insert_rule->execute( $hold_allowed_from_home_library ); |
|
|
187 |
|
182 |
|
188 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
183 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
189 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
184 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
Lines 195-202
AddReturn( $item1->{barcode} );
Link Here
|
195 |
} |
190 |
} |
196 |
|
191 |
|
197 |
{ |
192 |
{ |
198 |
$sth_delete_rules->execute; |
193 |
set_holdallowed_rule( $hold_allowed_from_any_libraries ); |
199 |
$sth_insert_rule->execute( $hold_allowed_from_any_libraries ); |
|
|
200 |
|
194 |
|
201 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
195 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
202 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
196 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
Lines 253-255
is( $is, 1, "Item can be held, items in transit are not available" );
Link Here
|
253 |
|
247 |
|
254 |
# Cleanup |
248 |
# Cleanup |
255 |
$schema->storage->txn_rollback; |
249 |
$schema->storage->txn_rollback; |
256 |
- |
250 |
|
|
|
251 |
sub set_holdallowed_rule { |
252 |
my ( $holdallowed ) = @_; |
253 |
Koha::CirculationRules->set_rules( |
254 |
{ |
255 |
branchcode => undef, |
256 |
categorycode => undef, |
257 |
itemtype => undef, |
258 |
rules => { |
259 |
holdallowed => $holdallowed, |
260 |
hold_fulfillment_policy => 'any', |
261 |
returnbranch => 'homebranch', |
262 |
} |
263 |
} |
264 |
); |
265 |
} |