Line 0
Link Here
|
0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
use Modern::Perl; |
4 |
use Test::More tests => 1; |
5 |
|
6 |
use t::lib::Mocks; |
7 |
use t::lib::TestBuilder; |
8 |
|
9 |
use C4::Reserves; |
10 |
use Koha::Database; |
11 |
use Koha::DateUtils; |
12 |
use Koha::Holds; |
13 |
|
14 |
my $schema = Koha::Database->new->schema; |
15 |
$schema->storage->txn_begin; |
16 |
|
17 |
subtest 'AutoUnsuspendReserves test' => sub { |
18 |
plan tests => 2; |
19 |
|
20 |
my $builder = t::lib::TestBuilder->new(); |
21 |
|
22 |
my $today = dt_from_string(); |
23 |
my $today_date = output_pref({ dateformat => 'sql' }); |
24 |
my $tomorrow_date = output_pref({ dt => $today->add(days=>1), dateformat=>'sql' }); |
25 |
|
26 |
# Reserve not expired |
27 |
my $reserve1 = $builder->build({ |
28 |
source => 'Reserve', |
29 |
value => { |
30 |
expirationdate => undef, |
31 |
cancellationdate => undef, |
32 |
priority => 5, |
33 |
found => undef, |
34 |
suspend_until => $today_date, |
35 |
}, |
36 |
}); |
37 |
# Reserve expired |
38 |
my $reserve2 = $builder->build({ |
39 |
source => 'Reserve', |
40 |
value => { |
41 |
expirationdate => undef, |
42 |
cancellationdate => undef, |
43 |
priority => 6, |
44 |
found => undef, |
45 |
suspend_until => $tomorrow_date, |
46 |
}, |
47 |
}); |
48 |
|
49 |
AutoUnsuspendReserves(); |
50 |
my $r1 = Koha::Holds->find($reserve1->{reserve_id}); |
51 |
my $r2 = Koha::Holds->find($reserve2->{reserve_id}); |
52 |
ok(!defined($r1->suspend_until), 'Reserve suspended until today should be unsuspended.'); |
53 |
ok(defined($r2->suspend_until), 'Reserve suspended after today should be suspended.'); |
54 |
|
55 |
}; |
56 |
|
57 |
$schema->storage->txn_rollback; |