|
Lines 20-26
Link Here
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::NoWarnings; |
22 |
use Test::NoWarnings; |
| 23 |
use Test::More tests => 14; |
23 |
use Test::More tests => 15; |
| 24 |
use Test::Warn; |
24 |
use Test::Warn; |
| 25 |
|
25 |
|
| 26 |
use C4::Circulation qw( AddIssue ); |
26 |
use C4::Circulation qw( AddIssue ); |
|
Lines 466-473
subtest 'cancel' => sub {
Link Here
|
| 466 |
my $reserve_id = C4::Reserves::AddReserve($hold_info); |
466 |
my $reserve_id = C4::Reserves::AddReserve($hold_info); |
| 467 |
Koha::Holds->find($reserve_id)->cancel; |
467 |
Koha::Holds->find($reserve_id)->cancel; |
| 468 |
my $number_of_logs = |
468 |
my $number_of_logs = |
| 469 |
$schema->resultset('ActionLog') |
469 |
$schema->resultset('ActionLog')->search( { module => 'HOLDS', action => 'CANCEL', object => $reserve_id } ) |
| 470 |
->search( { module => 'HOLDS', action => 'CANCEL', object => $reserve_id } ) |
|
|
| 471 |
->count; |
470 |
->count; |
| 472 |
is( $number_of_logs, 0, 'Without HoldsLog, Koha::Hold->cancel should not have logged' ); |
471 |
is( $number_of_logs, 0, 'Without HoldsLog, Koha::Hold->cancel should not have logged' ); |
| 473 |
|
472 |
|
|
Lines 475-482
subtest 'cancel' => sub {
Link Here
|
| 475 |
$reserve_id = C4::Reserves::AddReserve($hold_info); |
474 |
$reserve_id = C4::Reserves::AddReserve($hold_info); |
| 476 |
Koha::Holds->find($reserve_id)->cancel; |
475 |
Koha::Holds->find($reserve_id)->cancel; |
| 477 |
$number_of_logs = |
476 |
$number_of_logs = |
| 478 |
$schema->resultset('ActionLog') |
477 |
$schema->resultset('ActionLog')->search( { module => 'HOLDS', action => 'CANCEL', object => $reserve_id } ) |
| 479 |
->search( { module => 'HOLDS', action => 'CANCEL', object => $reserve_id } ) |
|
|
| 480 |
->count; |
478 |
->count; |
| 481 |
is( $number_of_logs, 1, 'With HoldsLog, Koha::Hold->cancel should have logged' ); |
479 |
is( $number_of_logs, 1, 'With HoldsLog, Koha::Hold->cancel should have logged' ); |
| 482 |
}; |
480 |
}; |
|
Lines 1296-1298
subtest 'processing() tests' => sub {
Link Here
|
| 1296 |
|
1294 |
|
| 1297 |
$schema->storage->txn_rollback; |
1295 |
$schema->storage->txn_rollback; |
| 1298 |
}; |
1296 |
}; |
| 1299 |
- |
1297 |
|
|
|
1298 |
subtest 'item_level_holds_count() tests' => sub { |
| 1299 |
plan tests => 6; |
| 1300 |
|
| 1301 |
$schema->storage->txn_begin; |
| 1302 |
|
| 1303 |
my $biblio = $builder->build_sample_biblio; |
| 1304 |
my $item_1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); |
| 1305 |
my $item_2 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); |
| 1306 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 1307 |
my $other_patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 1308 |
|
| 1309 |
# Create a biblio-level hold for the patron |
| 1310 |
my $biblio_hold = $builder->build_object( |
| 1311 |
{ |
| 1312 |
class => 'Koha::Holds', |
| 1313 |
value => { |
| 1314 |
borrowernumber => $patron->borrowernumber, |
| 1315 |
biblionumber => $biblio->biblionumber, |
| 1316 |
itemnumber => undef, |
| 1317 |
item_level_hold => 0, |
| 1318 |
} |
| 1319 |
} |
| 1320 |
); |
| 1321 |
|
| 1322 |
is( $biblio_hold->item_level_holds_count, 0, 'No item-level holds yet for this patron/biblio' ); |
| 1323 |
|
| 1324 |
# Create first item-level hold for the patron |
| 1325 |
my $item_hold_1 = $builder->build_object( |
| 1326 |
{ |
| 1327 |
class => 'Koha::Holds', |
| 1328 |
value => { |
| 1329 |
borrowernumber => $patron->borrowernumber, |
| 1330 |
biblionumber => $biblio->biblionumber, |
| 1331 |
itemnumber => $item_1->itemnumber, |
| 1332 |
item_level_hold => 1, |
| 1333 |
} |
| 1334 |
} |
| 1335 |
); |
| 1336 |
|
| 1337 |
is( $item_hold_1->item_level_holds_count, 1, 'One item-level hold for this patron/biblio' ); |
| 1338 |
is( $biblio_hold->item_level_holds_count, 1, 'Biblio-level hold also sees the item-level hold count' ); |
| 1339 |
|
| 1340 |
# Create second item-level hold for the patron |
| 1341 |
my $item_hold_2 = $builder->build_object( |
| 1342 |
{ |
| 1343 |
class => 'Koha::Holds', |
| 1344 |
value => { |
| 1345 |
borrowernumber => $patron->borrowernumber, |
| 1346 |
biblionumber => $biblio->biblionumber, |
| 1347 |
itemnumber => $item_2->itemnumber, |
| 1348 |
item_level_hold => 1, |
| 1349 |
} |
| 1350 |
} |
| 1351 |
); |
| 1352 |
|
| 1353 |
is( $item_hold_2->item_level_holds_count, 2, 'Two item-level holds for this patron/biblio' ); |
| 1354 |
|
| 1355 |
# Create item-level hold for different patron - should not be counted |
| 1356 |
my $other_patron_hold = $builder->build_object( |
| 1357 |
{ |
| 1358 |
class => 'Koha::Holds', |
| 1359 |
value => { |
| 1360 |
borrowernumber => $other_patron->borrowernumber, |
| 1361 |
biblionumber => $biblio->biblionumber, |
| 1362 |
itemnumber => $item_1->itemnumber, |
| 1363 |
item_level_hold => 1, |
| 1364 |
} |
| 1365 |
} |
| 1366 |
); |
| 1367 |
|
| 1368 |
is( $item_hold_1->item_level_holds_count, 2, 'Still two item-level holds for original patron' ); |
| 1369 |
is( $other_patron_hold->item_level_holds_count, 1, 'Only one item-level hold for other patron' ); |
| 1370 |
|
| 1371 |
$schema->storage->txn_rollback; |
| 1372 |
}; |