Lines 6-11
use C4::Context;
Link Here
|
6 |
use C4::Circulation qw( AddIssue AddReturn ); |
6 |
use C4::Circulation qw( AddIssue AddReturn ); |
7 |
use C4::Items; |
7 |
use C4::Items; |
8 |
use Koha::Items; |
8 |
use Koha::Items; |
|
|
9 |
use Koha::Cache::Memory::Lite; |
9 |
use Koha::CirculationRules; |
10 |
use Koha::CirculationRules; |
10 |
|
11 |
|
11 |
use Test::More tests => 13; |
12 |
use Test::More tests => 13; |
Lines 20-25
BEGIN {
Link Here
|
20 |
my $schema = Koha::Database->schema; |
21 |
my $schema = Koha::Database->schema; |
21 |
$schema->storage->txn_begin; |
22 |
$schema->storage->txn_begin; |
22 |
my $dbh = C4::Context->dbh; |
23 |
my $dbh = C4::Context->dbh; |
|
|
24 |
my $cache = Koha::Cache::Memory::Lite->get_instance(); |
23 |
|
25 |
|
24 |
my $builder = t::lib::TestBuilder->new; |
26 |
my $builder = t::lib::TestBuilder->new; |
25 |
|
27 |
|
Lines 113-118
$is = IsAvailableForItemLevelRequest( $item1, $patron1 );
Link Here
|
113 |
is( $is, 0, "Item cannot be held, 1 item available" ); |
115 |
is( $is, 0, "Item cannot be held, 1 item available" ); |
114 |
|
116 |
|
115 |
AddIssue( $patron2->unblessed, $item2->barcode ); |
117 |
AddIssue( $patron2->unblessed, $item2->barcode ); |
|
|
118 |
$cache->flush(); |
116 |
|
119 |
|
117 |
$is = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblionumber, patron => $patron1 } ); |
120 |
$is = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblionumber, patron => $patron1 } ); |
118 |
is( $is, 0, "Items availability: none of items are available" ); |
121 |
is( $is, 0, "Items availability: none of items are available" ); |
Lines 159-164
AddReturn( $item1->barcode );
Link Here
|
159 |
set_holdallowed_rule( $hold_allowed_from_any_libraries, $library_B ); |
162 |
set_holdallowed_rule( $hold_allowed_from_any_libraries, $library_B ); |
160 |
|
163 |
|
161 |
#Adding a rule for the item's home library affects the availability for a borrower from another library because ReservesControlBranch is set to ItemHomeLibrary |
164 |
#Adding a rule for the item's home library affects the availability for a borrower from another library because ReservesControlBranch is set to ItemHomeLibrary |
|
|
165 |
$cache->flush(); |
162 |
|
166 |
|
163 |
$is = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblionumber, patron => $patron1 } ); # patron1 in library A, library A 0 items, library B 1 item |
167 |
$is = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblionumber, patron => $patron1 } ); # patron1 in library A, library A 0 items, library B 1 item |
164 |
is( $is, 1, |
168 |
is( $is, 1, |
Lines 170-175
AddReturn( $item1->barcode );
Link Here
|
170 |
. "One item is available at different library, holdable = one available => the hold is not allowed at item level" ); |
174 |
. "One item is available at different library, holdable = one available => the hold is not allowed at item level" ); |
171 |
|
175 |
|
172 |
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'PatronLibrary' ); |
176 |
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'PatronLibrary' ); |
|
|
177 |
$cache->flush(); |
173 |
|
178 |
|
174 |
$is = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblionumber, patron => $patron1 } ); # patron1 in library A, library A 0 items, library B 1 item |
179 |
$is = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblionumber, patron => $patron1 } ); # patron1 in library A, library A 0 items, library B 1 item |
175 |
is( $is, 0, |
180 |
is( $is, 0, |
Lines 182-187
AddReturn( $item1->barcode );
Link Here
|
182 |
|
187 |
|
183 |
#Adding a rule for the patron's home library affects the availability for an item from another library because ReservesControlBranch is set to PatronLibrary |
188 |
#Adding a rule for the patron's home library affects the availability for an item from another library because ReservesControlBranch is set to PatronLibrary |
184 |
set_holdallowed_rule( $hold_allowed_from_any_libraries, $library_A ); |
189 |
set_holdallowed_rule( $hold_allowed_from_any_libraries, $library_A ); |
|
|
190 |
$cache->flush(); |
185 |
|
191 |
|
186 |
$is = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblionumber, patron => $patron1 } ); # patron1 in library A, library A 0 items, library B 1 item |
192 |
$is = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblionumber, patron => $patron1 } ); # patron1 in library A, library A 0 items, library B 1 item |
187 |
is( $is, 1, |
193 |
is( $is, 1, |
Lines 197-202
AddReturn( $item1->barcode );
Link Here
|
197 |
set_holdallowed_rule($hold_allowed_from_any_libraries); |
203 |
set_holdallowed_rule($hold_allowed_from_any_libraries); |
198 |
|
204 |
|
199 |
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'ItemHomeLibrary' ); |
205 |
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'ItemHomeLibrary' ); |
|
|
206 |
$cache->flush(); |
200 |
|
207 |
|
201 |
$is = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblionumber, patron => $patron1 } ); # patron1 in library A, library A 0 items, library B 1 item |
208 |
$is = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblionumber, patron => $patron1 } ); # patron1 in library A, library A 0 items, library B 1 item |
202 |
is( $is, 1, "Items availability: hold allowed from any library + ReservesControlBranch=ItemHomeLibrary + one item is available at different library" ); |
209 |
is( $is, 1, "Items availability: hold allowed from any library + ReservesControlBranch=ItemHomeLibrary + one item is available at different library" ); |
Lines 207-212
AddReturn( $item1->barcode );
Link Here
|
207 |
. "One item is available at the diff library, holdable = 1 available => the hold is not allowed at item level" ); |
214 |
. "One item is available at the diff library, holdable = 1 available => the hold is not allowed at item level" ); |
208 |
|
215 |
|
209 |
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'PatronLibrary' ); |
216 |
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'PatronLibrary' ); |
|
|
217 |
$cache->flush(); |
210 |
|
218 |
|
211 |
$is = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblionumber, patron => $patron1 } ); # patron1 in library A, library A 0 items, library B 1 item |
219 |
$is = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblionumber, patron => $patron1 } ); # patron1 in library A, library A 0 items, library B 1 item |
212 |
is( $is, 1, "Items availability: hold allowed from any library + ReservesControlBranch=PatronLibrary + one item is available at different library" ); |
220 |
is( $is, 1, "Items availability: hold allowed from any library + ReservesControlBranch=PatronLibrary + one item is available at different library" ); |
Lines 380-385
subtest 'Check holds availability with different item types' => sub {
Link Here
|
380 |
is( $is, 0, "Item5 cannot be requested to hold: 2 items, Item4 available, Item5 restricted" ); |
388 |
is( $is, 0, "Item5 cannot be requested to hold: 2 items, Item4 available, Item5 restricted" ); |
381 |
|
389 |
|
382 |
AddIssue( $patron2->unblessed, $item4->barcode ); |
390 |
AddIssue( $patron2->unblessed, $item4->barcode ); |
|
|
391 |
$cache->flush(); |
383 |
|
392 |
|
384 |
$is = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblio2->biblionumber, patron => $patron1 } ); |
393 |
$is = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblio2->biblionumber, patron => $patron1 } ); |
385 |
is( $is, 0, "Items availability: 2 items, one allowed by smart rule and checked out, another one not allowed to be held by smart rule" ); |
394 |
is( $is, 0, "Items availability: 2 items, one allowed by smart rule and checked out, another one not allowed to be held by smart rule" ); |
Lines 419-424
subtest 'Check item checkout availability with ordered item' => sub {
Link Here
|
419 |
} |
428 |
} |
420 |
} |
429 |
} |
421 |
); |
430 |
); |
|
|
431 |
$cache->flush(); |
422 |
|
432 |
|
423 |
$is = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblio2->biblionumber, patron => $patron1 } ); |
433 |
$is = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblio2->biblionumber, patron => $patron1 } ); |
424 |
is( $is, 0, "Ordered item cannot be checked out" ); |
434 |
is( $is, 0, "Ordered item cannot be checked out" ); |
Lines 452-457
subtest 'Check item availability for hold with ordered item' => sub {
Link Here
|
452 |
} |
462 |
} |
453 |
); |
463 |
); |
454 |
|
464 |
|
|
|
465 |
$cache->flush(); |
455 |
$is = IsAvailableForItemLevelRequest( $item1, $patron1 ); |
466 |
$is = IsAvailableForItemLevelRequest( $item1, $patron1 ); |
456 |
is( $is, 1, "Ordered items are available for hold" ); |
467 |
is( $is, 1, "Ordered items are available for hold" ); |
457 |
}; |
468 |
}; |
458 |
- |
|
|