4 use Test::More tests => 1;
6 use Koha::Authority::MergeRequest;
7 use Koha::Authority::MergeRequests;
9 use Koha::DateUtils qw/dt_from_string/;
11 my $schema = Koha::Database->new->schema;
12 $schema->storage->txn_begin;
14 subtest "Tests for cron_cleanup" => sub {
17 my $dt = dt_from_string;
18 $dt->subtract( hours => 2 );
19 my $req1 = Koha::Authority::MergeRequest->new({
25 $dt->subtract( days => 30 );
26 my $req2 = Koha::Authority::MergeRequest->new({
32 # Now test two cleanup calls
33 # First call should only remove req2; second call should reset req1
34 Koha::Authority::MergeRequests->cron_cleanup({ reset_hours => 3 });
35 $req1->discard_changes; # requery
36 is( $req1->done, 2, 'My request was not touched' );
37 $req2->discard_changes; # requery
38 is( $req2->in_storage, 0, 'Second request removed' );
39 Koha::Authority::MergeRequests->cron_cleanup({ reset_hours => 1 });
40 $req1->discard_changes; # requery
41 is( $req1->done, 0, 'Yes, we got a reset' );
44 $schema->storage->txn_rollback;