Bug 31378: (follow-up) Fix t/Koha/Auth/Permissions.t
[koha.git] / t / timezones.t
1 use Modern::Perl;
2
3 use C4::Context;
4 use Koha::Config;
5
6 use Test::More tests => 5;
7 use Test::Warn;
8 use t::lib::Mocks;
9
10 $ENV{TZ} = q{};
11 t::lib::Mocks::mock_config( 'timezone', q{} );
12 my $config = Koha::Config->get_instance;
13 is( $config->timezone, 'local',
14     'Got local timezone with no env or config timezone set' );
15
16 $ENV{TZ} = 'Antarctica/Macquarie';
17 is(
18     $config->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     $config->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( $config->timezone, 'local', 'Invalid timezone falls back to local' ); }
33     'Invalid timezone in koha-conf.xml (Your/Timezone)',
34     'Invalid timezone raises a warning';