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