|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 72; |
20 |
use Test::More tests => 73; |
| 21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
| 22 |
use Test::Warn; |
22 |
use Test::Warn; |
| 23 |
|
23 |
|
|
Lines 786-791
subtest '_koha_notify_reserve() tests' => sub {
Link Here
|
| 786 |
|
786 |
|
| 787 |
}; |
787 |
}; |
| 788 |
|
788 |
|
|
|
789 |
subtest 'CancelExpiredReserves tests' => sub { |
| 790 |
plan tests => 2; |
| 791 |
|
| 792 |
$dbh->do('DELETE FROM reserves'); |
| 793 |
|
| 794 |
my $category = $builder->build({ source => 'Category' }); |
| 795 |
my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode }; |
| 796 |
|
| 797 |
my $borrowernumber = AddMember( |
| 798 |
firstname => 'my firstname', |
| 799 |
surname => 'my surname', |
| 800 |
categorycode => $category->{categorycode}, |
| 801 |
branchcode => $branchcode, |
| 802 |
); |
| 803 |
|
| 804 |
my $resdate = dt_from_string->add( days => -20 ); |
| 805 |
my $expdate = dt_from_string->add( days => -2 ); |
| 806 |
my $notexpdate = dt_from_string->add( days => 2 ); |
| 807 |
|
| 808 |
my $hold1 = Koha::Hold->new({ |
| 809 |
branchcode => $branchcode, |
| 810 |
borrowernumber => $borrowernumber, |
| 811 |
biblionumber => $bibnum, |
| 812 |
priority => 1, |
| 813 |
reservedate => $resdate, |
| 814 |
expirationdate => $notexpdate, |
| 815 |
found => undef |
| 816 |
})->store; |
| 817 |
|
| 818 |
my $hold2 = Koha::Hold->new({ |
| 819 |
branchcode => $branchcode, |
| 820 |
borrowernumber => $borrowernumber, |
| 821 |
biblionumber => $bibnum, |
| 822 |
priority => 2, |
| 823 |
reservedate => $resdate, |
| 824 |
expirationdate => $expdate, |
| 825 |
found => undef |
| 826 |
})->store; |
| 827 |
|
| 828 |
my $hold3 = Koha::Hold->new({ |
| 829 |
branchcode => $branchcode, |
| 830 |
borrowernumber => $borrowernumber, |
| 831 |
biblionumber => $bibnum, |
| 832 |
itemnumber => $itemnumber, |
| 833 |
priority => 0, |
| 834 |
reservedate => $resdate, |
| 835 |
expirationdate => $expdate, |
| 836 |
found => 'W' |
| 837 |
})->store; |
| 838 |
|
| 839 |
t::lib::Mocks::mock_preference( 'ExpireReservesMaxPickUpDelay', 0 ); |
| 840 |
CancelExpiredReserves(); |
| 841 |
my $count1 = Koha::Holds->search->count; |
| 842 |
is( $count1, 2, 'Only the non-waiting expired holds should be cancelled'); |
| 843 |
|
| 844 |
t::lib::Mocks::mock_preference( 'ExpireReservesMaxPickUpDelay', 1 ); |
| 845 |
CancelExpiredReserves(); |
| 846 |
my $count2 = Koha::Holds->search->count; |
| 847 |
is( $count2, 1, 'Also the waiting expired hold should be cancelled now'); |
| 848 |
}; |
| 849 |
|
| 789 |
sub count_hold_print_messages { |
850 |
sub count_hold_print_messages { |
| 790 |
my $message_count = $dbh->selectall_arrayref(q{ |
851 |
my $message_count = $dbh->selectall_arrayref(q{ |
| 791 |
SELECT COUNT(*) |
852 |
SELECT COUNT(*) |
| 792 |
- |
|
|