|
Lines 118-126
AddReturn( $item1->{barcode} );
Link Here
|
| 118 |
|
118 |
|
| 119 |
my $hold_allowed_from_home_library = 1; |
119 |
my $hold_allowed_from_home_library = 1; |
| 120 |
my $hold_allowed_from_any_libraries = 2; |
120 |
my $hold_allowed_from_any_libraries = 2; |
| 121 |
my $sth_delete_rules = $dbh->prepare(q|DELETE FROM default_circ_rules|); |
|
|
| 122 |
my $sth_insert_rule = $dbh->prepare(q|INSERT INTO default_circ_rules(singleton, holdallowed, hold_fulfillment_policy, returnbranch) VALUES ('singleton', ?, 'any', 'homebranch');|); |
| 123 |
my $sth_insert_branch_rule = $dbh->prepare(q|INSERT INTO default_branch_circ_rules(branchcode, holdallowed, hold_fulfillment_policy, returnbranch) VALUES (?, ?, 'any', 'homebranch');|); |
| 124 |
|
121 |
|
| 125 |
subtest 'Item is available at a different library' => sub { |
122 |
subtest 'Item is available at a different library' => sub { |
| 126 |
plan tests => 7; |
123 |
plan tests => 7; |
|
Lines 135-149
AddReturn( $item1->{barcode} );
Link Here
|
| 135 |
#Borrower1 is from library A |
132 |
#Borrower1 is from library A |
| 136 |
|
133 |
|
| 137 |
{ |
134 |
{ |
| 138 |
$sth_delete_rules->execute; |
135 |
set_holdallowed_rule( $hold_allowed_from_home_library ); |
| 139 |
$sth_insert_rule->execute( $hold_allowed_from_home_library ); |
|
|
| 140 |
|
136 |
|
| 141 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
137 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
| 142 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
138 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
| 143 |
is( $is, 1, "Hold allowed from home library + ReservesControlBranch=ItemHomeLibrary, One item is available at different library, not holdable = none available => the hold is allowed at item level" ); |
139 |
is( $is, 1, "Hold allowed from home library + ReservesControlBranch=ItemHomeLibrary, One item is available at different library, not holdable = none available => the hold is allowed at item level" ); |
| 144 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower2); |
140 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower2); |
| 145 |
is( $is, 1, "Hold allowed from home library + ReservesControlBranch=ItemHomeLibrary, One item is available at home library, holdable = one available => the hold is not allowed at item level" ); |
141 |
is( $is, 1, "Hold allowed from home library + ReservesControlBranch=ItemHomeLibrary, One item is available at home library, holdable = one available => the hold is not allowed at item level" ); |
| 146 |
$sth_insert_branch_rule->execute( $library_B, $hold_allowed_from_any_libraries ); |
142 |
set_holdallowed_rule( $hold_allowed_from_any_libraries, $library_B ); |
| 147 |
#Adding a rule for the item's home library affects the availability for a borrower from another library because ReservesControlBranch is set to ItemHomeLibrary |
143 |
#Adding a rule for the item's home library affects the availability for a borrower from another library because ReservesControlBranch is set to ItemHomeLibrary |
| 148 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
144 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
| 149 |
is( $is, 0, "Hold allowed from home library + ReservesControlBranch=ItemHomeLibrary, One item is available at different library, holdable = one available => the hold is not allowed at item level" ); |
145 |
is( $is, 0, "Hold allowed from home library + ReservesControlBranch=ItemHomeLibrary, One item is available at different library, holdable = one available => the hold is not allowed at item level" ); |
|
Lines 152-165
AddReturn( $item1->{barcode} );
Link Here
|
| 152 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
148 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
| 153 |
is( $is, 1, "Hold allowed from home library + ReservesControlBranch=PatronLibrary, One item is available at different library, not holdable = none available => the hold is allowed at item level" ); |
149 |
is( $is, 1, "Hold allowed from home library + ReservesControlBranch=PatronLibrary, One item is available at different library, not holdable = none available => the hold is allowed at item level" ); |
| 154 |
#Adding a rule for the patron's home library affects the availability for an item from another library because ReservesControlBranch is set to PatronLibrary |
150 |
#Adding a rule for the patron's home library affects the availability for an item from another library because ReservesControlBranch is set to PatronLibrary |
| 155 |
$sth_insert_branch_rule->execute( $library_A, $hold_allowed_from_any_libraries ); |
151 |
set_holdallowed_rule( $hold_allowed_from_any_libraries, $library_A ); |
| 156 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
152 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
| 157 |
is( $is, 0, "Hold allowed from home library + ReservesControlBranch=PatronLibrary, One item is available at different library, holdable = one available => the hold is not allowed at item level" ); |
153 |
is( $is, 0, "Hold allowed from home library + ReservesControlBranch=PatronLibrary, One item is available at different library, holdable = one available => the hold is not allowed at item level" ); |
| 158 |
} |
154 |
} |
| 159 |
|
155 |
|
| 160 |
{ |
156 |
{ |
| 161 |
$sth_delete_rules->execute; |
157 |
set_holdallowed_rule( $hold_allowed_from_any_libraries ); |
| 162 |
$sth_insert_rule->execute( $hold_allowed_from_any_libraries ); |
|
|
| 163 |
|
158 |
|
| 164 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
159 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
| 165 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
160 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
|
Lines 186-193
AddReturn( $item1->{barcode} );
Link Here
|
| 186 |
#ReservesControlBranch is not checked in these subs we are testing? |
181 |
#ReservesControlBranch is not checked in these subs we are testing? |
| 187 |
|
182 |
|
| 188 |
{ |
183 |
{ |
| 189 |
$sth_delete_rules->execute; |
184 |
set_holdallowed_rule( $hold_allowed_from_home_library ); |
| 190 |
$sth_insert_rule->execute( $hold_allowed_from_home_library ); |
|
|
| 191 |
|
185 |
|
| 192 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
186 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
| 193 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
187 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
|
Lines 199-206
AddReturn( $item1->{barcode} );
Link Here
|
| 199 |
} |
193 |
} |
| 200 |
|
194 |
|
| 201 |
{ |
195 |
{ |
| 202 |
$sth_delete_rules->execute; |
196 |
set_holdallowed_rule( $hold_allowed_from_any_libraries ); |
| 203 |
$sth_insert_rule->execute( $hold_allowed_from_any_libraries ); |
|
|
| 204 |
|
197 |
|
| 205 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
198 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
| 206 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
199 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
|
Lines 246-248
is( $is, 1, "Item can be held, items in transit are not available" );
Link Here
|
| 246 |
|
239 |
|
| 247 |
# Cleanup |
240 |
# Cleanup |
| 248 |
$schema->storage->txn_rollback; |
241 |
$schema->storage->txn_rollback; |
| 249 |
- |
242 |
|
|
|
243 |
sub set_holdallowed_rule { |
| 244 |
my ( $holdallowed, $branchcode ) = @_; |
| 245 |
Koha::CirculationRules->set_rules( |
| 246 |
{ |
| 247 |
branchcode => $branchcode || undef, |
| 248 |
categorycode => undef, |
| 249 |
itemtype => undef, |
| 250 |
rules => { |
| 251 |
holdallowed => $holdallowed, |
| 252 |
hold_fulfillment_policy => 'any', |
| 253 |
returnbranch => 'homebranch', |
| 254 |
} |
| 255 |
} |
| 256 |
); |
| 257 |
} |