|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 58; |
20 |
use Test::More tests => 59; |
| 21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
| 22 |
use Test::Warn; |
22 |
use Test::Warn; |
| 23 |
|
23 |
|
|
Lines 692-697
subtest '_koha_notify_reserve() tests' => sub {
Link Here
|
| 692 |
|
692 |
|
| 693 |
}; |
693 |
}; |
| 694 |
|
694 |
|
|
|
695 |
subtest 'CancelExpiredReserves tests' => sub { |
| 696 |
plan tests => 2; |
| 697 |
|
| 698 |
$dbh->do('DELETE FROM reserves'); |
| 699 |
|
| 700 |
my $category = $builder->build({ source => 'Category' }); |
| 701 |
my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode }; |
| 702 |
|
| 703 |
my $borrowernumber = AddMember( |
| 704 |
firstname => 'my firstname', |
| 705 |
surname => 'my surname', |
| 706 |
categorycode => $category->{categorycode}, |
| 707 |
branchcode => $branchcode, |
| 708 |
); |
| 709 |
|
| 710 |
my $resdate = dt_from_string->add( days => -20 ); |
| 711 |
my $expdate = dt_from_string->add( days => -2 ); |
| 712 |
my $notexpdate = dt_from_string->add( days => 2 ); |
| 713 |
|
| 714 |
my $hold1 = Koha::Hold->new({ |
| 715 |
branchcode => $branchcode, |
| 716 |
borrowernumber => $borrowernumber, |
| 717 |
biblionumber => $bibnum, |
| 718 |
priority => 1, |
| 719 |
reservedate => $resdate, |
| 720 |
expirationdate => $notexpdate, |
| 721 |
found => undef |
| 722 |
})->store; |
| 723 |
|
| 724 |
my $hold2 = Koha::Hold->new({ |
| 725 |
branchcode => $branchcode, |
| 726 |
borrowernumber => $borrowernumber, |
| 727 |
biblionumber => $bibnum, |
| 728 |
priority => 2, |
| 729 |
reservedate => $resdate, |
| 730 |
expirationdate => $expdate, |
| 731 |
found => undef |
| 732 |
})->store; |
| 733 |
|
| 734 |
my $hold3 = Koha::Hold->new({ |
| 735 |
branchcode => $branchcode, |
| 736 |
borrowernumber => $borrowernumber, |
| 737 |
biblionumber => $bibnum, |
| 738 |
itemnumber => $itemnumber, |
| 739 |
priority => 0, |
| 740 |
reservedate => $resdate, |
| 741 |
expirationdate => $expdate, |
| 742 |
found => 'W' |
| 743 |
})->store; |
| 744 |
|
| 745 |
t::lib::Mocks::mock_preference( 'ExpireReservesMaxPickUpDelay', 0 ); |
| 746 |
CancelExpiredReserves(); |
| 747 |
my $count1 = Koha::Holds->search->count; |
| 748 |
is( $count1, 2, 'Only the non-waiting expired holds should be cancelled'); |
| 749 |
|
| 750 |
t::lib::Mocks::mock_preference( 'ExpireReservesMaxPickUpDelay', 1 ); |
| 751 |
CancelExpiredReserves(); |
| 752 |
my $count2 = Koha::Holds->search->count; |
| 753 |
is( $count2, 1, 'Also the waiting expired hold should be cancelled now'); |
| 754 |
}; |
| 755 |
|
| 695 |
sub count_hold_print_messages { |
756 |
sub count_hold_print_messages { |
| 696 |
my $message_count = $dbh->selectall_arrayref(q{ |
757 |
my $message_count = $dbh->selectall_arrayref(q{ |
| 697 |
SELECT COUNT(*) |
758 |
SELECT COUNT(*) |
| 698 |
- |
|
|