aboutsummaryrefslogtreecommitdiffstats
path: root/t/04-Shared_TimeZone.t
blob: f11bb2c6b47d60f19a3cc2eb6bec0f4a05675a8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use 5.006;
use strict;
use warnings FATAL => 'all';
use Test::More;
use Data::Dumper;
use Time::Piece;

BEGIN {
    use_ok( 'AdminPanel::Shared::TimeZone' ) || print "AdminPanel::Shared::TimeZone failed!\n";
}

    ok( my $tz = AdminPanel::Shared::TimeZone->new(), 'create');
    is( $tz->get_timezone_prefix(), '/usr/share/zoneinfo', 'get_timezone_prefix' );
    ok (my @l = $tz->getTimeZones(), 'getTimeZones');
    ok (my $h = $tz->readConfiguration(), 'readConfiguration');
    diag Dumper($h);
    ok (my $s = $tz->ntpCurrentServer(), 'currentNTPServer');
    diag "ntpCurrentServer got: < " . ($s ? $s : "none") . " >";
    ok (my $a = ($tz->isNTPRunning() ? "running" : "not running"), 'isNTPRunning');
    diag "isNTPRunning got: < " . $a . " >";

    SKIP: {
        #remember to skip the right number of tests
        skip "To enable dialog tests set TEST_SET_DBUS", 3, unless $ENV{TEST_SET_DBUS};
        eval {$tz->setLocalRTC(!$h->{UTC})};
        is ($@, "", 'setLocalRTC' );
        eval {$tz->setTimeZone($h->{ZONE})};
        is ($@, "", 'setTimeZone');
        my $t = localtime;
        eval {$tz->setTime($t->epoch())};
        is ($@, "", 'setTime');
    }
done_testing;