Bug 28385: Add tests
[koha.git] / t / timezones.t
1 use Modern::Perl;
2
3 use C4::Context;
4
5 use Test::More tests => 5;
6 use Test::Warn;
7 use t::lib::Mocks;
8
9 use DateTime::TimeZone;
10
11 $ENV{TZ} = q{};
12 t::lib::Mocks::mock_config( 'timezone', q{} );
13 is( C4::Context->timezone, 'local',
14     'Got local timezone with no env or config timezone set' );
15
16 $ENV{TZ} = 'Antarctica/Macquarie';
17 is(
18     C4::Context->timezone,
19     'Antarctica/Macquarie',
20     'Got correct timezone using ENV, overrides local time'
21 );
22
23 t::lib::Mocks::mock_config( 'timezone', 'Antarctica/South_Pole' );
24 is(
25     C4::Context->timezone,
26     'Antarctica/South_Pole',
27     'Got correct timezone using config, overrides env'
28 );
29
30 t::lib::Mocks::mock_config( 'timezone', 'Your/Timezone' );
31 warning_is {
32     is( C4::Context->timezone, 'local', 'Invalid timezone falls back to local' ); }
33     'Invalid timezone in koha-conf.xml (Your/Timezone)',
34     'Invalid timezone raises a warning';