View | Details | Raw Unified | Return to bug 17770
Collapse All | Expand All

(-)a/t/db_dependent/Sitemapper.t (-4 / +4 lines)
Lines 24-35 use DateTime; Link Here
24
use Test::MockModule;
24
use Test::MockModule;
25
use Test::More tests => 16;
25
use Test::More tests => 16;
26
use Koha::Schema;
26
use Koha::Schema;
27
use t::lib::Dates;
27
28
28
29
29
BEGIN {
30
t::lib::Dates::wait_till_midnight(1);
30
    use_ok('Koha::Sitemapper');
31
use_ok('Koha::Sitemapper');
31
    use_ok('Koha::Sitemapper::Writer');
32
use_ok('Koha::Sitemapper::Writer');
32
}
33
33
34
sub slurp {
34
sub slurp {
35
    my $file = shift;
35
    my $file = shift;
(-)a/t/lib/Dates.pm (-1 / +27 lines)
Lines 28-31 sub compare { Link Here
28
    return $diff > 0 ? 1 : -1;
28
    return $diff > 0 ? 1 : -1;
29
}
29
}
30
30
31
=head2 wait_till_midnight
32
33
  $test_duration = 1;
34
  t::lib::Dates::wait_till_midnight($test_duration);
35
36
Some tests that cross midnight wrongly fail. This waits
37
until after midnight to ensure that the failure is not time related.
38
39
I<test_duration> - The number of minutes the test takes to run
40
                   rounded up. Most run quickly, so a default
41
                   of 1 is sufficient when the parameter is
42
                   not passed.
43
44
=cut
45
46
sub wait_till_midnight {
47
    my ($test_duration) = @_;
48
    $test_duration = $test_duration // 1;
49
    my $current_time = DateTime->now();
50
    if ($current_time->hour == 23 && $current_time->minute >= (60-$test_duration)) {
51
        while ($current_time->hour == 23) {
52
            sleep(60);
53
            $current_time = DateTime->now();
54
        }
55
    }
56
}
57
31
1;
58
1;
32
- 

Return to bug 17770