Lines 1424-1436
subtest 'ModReserveAffect logging' => sub {
Link Here
|
1424 |
|
1424 |
|
1425 |
subtest 'Waiting item is marked as lost' => sub { |
1425 |
subtest 'Waiting item is marked as lost' => sub { |
1426 |
|
1426 |
|
1427 |
plan tests => 15; |
1427 |
plan tests => 17; |
1428 |
|
1428 |
|
1429 |
# Set up data |
1429 |
# Set up data |
1430 |
my $biblio = $builder->build_sample_biblio(); |
1430 |
my $biblio = $builder->build_sample_biblio(); |
1431 |
my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); |
1431 |
my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); |
1432 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
1432 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
1433 |
|
1433 |
t::lib::Mocks::mock_preference( 'SendLostHoldNotices', 0 ); |
|
|
1434 |
$dbh->do(q|DELETE FROM message_queue|); |
1434 |
## TEST 1: BIBLIO-LEVEL HOLD |
1435 |
## TEST 1: BIBLIO-LEVEL HOLD |
1435 |
|
1436 |
|
1436 |
# place biblio-level hold |
1437 |
# place biblio-level hold |
Lines 1441-1446
subtest 'Waiting item is marked as lost' => sub {
Link Here
|
1441 |
}); |
1442 |
}); |
1442 |
my $hold = Koha::Holds->find( $reserve_id ); |
1443 |
my $hold = Koha::Holds->find( $reserve_id ); |
1443 |
|
1444 |
|
|
|
1445 |
$dbh->do(q{INSERT IGNORE INTO letter (module, code, branchcode, name, is_html, title, message_transport_type, content) VALUES ('reserves','LOST_WAITING_HOLD','','Waiting hold marked lost','0','Your waiting hold has been marked lost','email',"Dear [% borrower.firstname %] [% borrowers.surname %],<br><br>Your hold awaiting pickup is no longer available. The item is lost.<br><br>Please contact the library for more information.<br><br>Thank you,<br><br>[% branch.branchname %]") }); |
1446 |
|
1444 |
is( $hold->item_level_hold, 0, 'Biblio-level hold placed' ); |
1447 |
is( $hold->item_level_hold, 0, 'Biblio-level hold placed' ); |
1445 |
|
1448 |
|
1446 |
# set hold as waiting and assign item |
1449 |
# set hold as waiting and assign item |
Lines 1508-1514
subtest 'Waiting item is marked as lost' => sub {
Link Here
|
1508 |
$hold->cancel; |
1511 |
$hold->cancel; |
1509 |
$item->itemlost( 0 ); |
1512 |
$item->itemlost( 0 ); |
1510 |
|
1513 |
|
|
|
1514 |
my $message_count = $dbh->selectall_arrayref(q{ |
1515 |
SELECT COUNT(*) |
1516 |
FROM message_queue |
1517 |
WHERE letter_code = 'LOST_WAITING_HOLD' |
1518 |
}); |
1519 |
is( $message_count->[0]->[0], 0, 'No notices enqueued because SendLostHoldNotices disabled' ); |
1520 |
|
1511 |
# TEST 3: ITEM-LEVEL HOLD, CANCEL |
1521 |
# TEST 3: ITEM-LEVEL HOLD, CANCEL |
|
|
1522 |
t::lib::Mocks::mock_preference( 'SendLostHoldNotices', 1 ); |
1512 |
|
1523 |
|
1513 |
# place item-level hold |
1524 |
# place item-level hold |
1514 |
$reserve_id = AddReserve({ |
1525 |
$reserve_id = AddReserve({ |
Lines 1542-1547
subtest 'Waiting item is marked as lost' => sub {
Link Here
|
1542 |
C4::Circulation::LostItem( $item->itemnumber, 'test', 0, { cancel_reserve => 1 }); |
1553 |
C4::Circulation::LostItem( $item->itemnumber, 'test', 0, { cancel_reserve => 1 }); |
1543 |
$hold = Koha::Holds->find( $reserve_id ); |
1554 |
$hold = Koha::Holds->find( $reserve_id ); |
1544 |
is( Koha::Holds->find( $reserve_id ), undef, 'Hold has been cancelled with RevertLostBibLevelHolds enabled' ); |
1555 |
is( Koha::Holds->find( $reserve_id ), undef, 'Hold has been cancelled with RevertLostBibLevelHolds enabled' ); |
|
|
1556 |
|
1557 |
$message_count = $dbh->selectall_arrayref(q{ |
1558 |
SELECT COUNT(*) |
1559 |
FROM message_queue |
1560 |
WHERE letter_code = 'LOST_WAITING_HOLD' |
1561 |
}); |
1562 |
is( $message_count->[0]->[0], 2, 'LOST_WAITING_HOLD notice enqueued with each call to LostItem' ); |
1545 |
}; |
1563 |
}; |
1546 |
|
1564 |
|
1547 |
sub count_hold_print_messages { |
1565 |
sub count_hold_print_messages { |
1548 |
- |
|
|