Koha/t/db_dependent/Authority/MergeRequests.t
Jonathan Druart f1f9c6dc74 Bug 26384: Fix executable flags
.pm must not have -x
.t must have -x
.pl must have -x

Test plan:
Apply only the first patch, run the tests and confirm that the failures
make sense
Apply this patch and confirm that the test now returns green

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2020-09-11 09:56:56 +02:00

44 lines
1.2 KiB
Perl
Executable file

#!/usr/bin/perl
use Modern::Perl;
use Test::More tests => 1;
use Koha::Authority::MergeRequest;
use Koha::Authority::MergeRequests;
use Koha::Database;
use Koha::DateUtils qw/dt_from_string/;
my $schema = Koha::Database->new->schema;
$schema->storage->txn_begin;
subtest "Tests for cron_cleanup" => sub {
plan tests => 3;
my $dt = dt_from_string;
$dt->subtract( hours => 2 );
my $req1 = Koha::Authority::MergeRequest->new({
authid => 1,
done => 2,
timestamp => $dt,
})->store;
$dt->subtract( days => 30 );
my $req2 = Koha::Authority::MergeRequest->new({
authid => 2,
done => 1,
timestamp => $dt,
})->store;
# Now test two cleanup calls
# First call should only remove req2; second call should reset req1
Koha::Authority::MergeRequests->cron_cleanup({ reset_hours => 3 });
$req1->discard_changes; # requery
is( $req1->done, 2, 'My request was not touched' );
$req2->discard_changes; # requery
is( $req2->in_storage, 0, 'Second request removed' );
Koha::Authority::MergeRequests->cron_cleanup({ reset_hours => 1 });
$req1->discard_changes; # requery
is( $req1->done, 0, 'Yes, we got a reset' );
};
$schema->storage->txn_rollback;