Bug 5549 : Add Koha directory to testcritic
[koha.git] / t / dateutils.t
1 use strict;
2 use warnings;
3 use 5.010;
4
5 use C4::Context;
6 use Test::More tests => 7;    # last test to print
7
8 BEGIN { use_ok('Koha::DateUtils'); }
9
10 my $tz = C4::Context->tz;
11
12 isa_ok( $tz, 'DateTime::TimeZone', 'Context returns timezone object' );
13
14 my $testdate_iso = '2011-06-16';                   # Bloomsday 2011
15 my $dt = dt_from_string( $testdate_iso, 'iso' );
16
17 isa_ok( $dt, 'DateTime', 'dt_from_string returns a DateTime object' );
18
19 cmp_ok( $dt->ymd(), 'eq', $testdate_iso, 'Returned object matches input' );
20
21 $dt->set_hour(12);
22 $dt->set_minute(0);
23
24 my $date_string = output_pref( $dt, 'iso' );
25 cmp_ok $date_string, 'eq', '2011-06-16 12:00', 'iso output';
26
27 $date_string = output_pref( $dt, 'us' );
28 cmp_ok $date_string, 'eq', '06/16/2011 12:00', 'us output';
29
30 # metric should return the French Revolutionary Calendar Really
31 $date_string = output_pref( $dt, 'metric' );
32 cmp_ok $date_string, 'eq', '16/06/2011 12:00', 'metric output';