|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 68; |
20 |
use Test::More tests => 69; |
| 21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
| 22 |
use Test::Warn; |
22 |
use Test::Warn; |
| 23 |
|
23 |
|
|
Lines 1362-1364
sub place_item_hold {
Link Here
|
| 1362 |
|
1362 |
|
| 1363 |
# we reached the finish |
1363 |
# we reached the finish |
| 1364 |
$schema->storage->txn_rollback(); |
1364 |
$schema->storage->txn_rollback(); |
| 1365 |
- |
1365 |
|
|
|
1366 |
subtest 'IsAvailableForItemLevelRequest() tests' => sub { |
| 1367 |
|
| 1368 |
plan tests => 2; |
| 1369 |
|
| 1370 |
$schema->storage->txn_begin; |
| 1371 |
|
| 1372 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 1373 |
|
| 1374 |
my $item_type = undef; |
| 1375 |
|
| 1376 |
my $item_mock = Test::MockModule->new('Koha::Item'); |
| 1377 |
$item_mock->mock( 'effective_itemtype', sub { return $item_type; } ); |
| 1378 |
|
| 1379 |
my $item = $builder->build_sample_item; |
| 1380 |
|
| 1381 |
ok( |
| 1382 |
!C4::Reserves::IsAvailableForItemLevelRequest( $item, $patron ), |
| 1383 |
"Item not available for item-level hold because no effective item type" |
| 1384 |
); |
| 1385 |
|
| 1386 |
# Weird use case to highlight issue |
| 1387 |
$item_type = '0'; |
| 1388 |
Koha::ItemTypes->search( { itemtype => $item_type } )->delete; |
| 1389 |
my $itemtype = $builder->build_object( |
| 1390 |
{ |
| 1391 |
class => 'Koha::ItemTypes', |
| 1392 |
value => { itemtype => $item_type, notloan => 0 } |
| 1393 |
} |
| 1394 |
); |
| 1395 |
ok( |
| 1396 |
C4::Reserves::IsAvailableForItemLevelRequest( $item, $patron ), |
| 1397 |
"Item not available for item-level hold because no effective item type" |
| 1398 |
); |
| 1399 |
|
| 1400 |
$schema->storage->txn_rollback; |
| 1401 |
}; |