Bug 24643: Add unit tests
authorAndrew Isherwood <andrew.isherwood@ptfs-europe.com>
Wed, 12 Feb 2020 16:28:58 +0000 (16:28 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 13 Feb 2020 15:56:42 +0000 (15:56 +0000)
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

t/DateUtils.t

index 02ed234..df49fcd 100755 (executable)
@@ -4,7 +4,7 @@ use DateTime::TimeZone;
 
 use C4::Context;
 
-use Test::More tests => 68;
+use Test::More tests => 71;
 
 use Test::MockModule;
 use Test::Warn;
@@ -125,6 +125,15 @@ isa_ok( $dt0, 'DateTime',
     'dt_from_string returns a DateTime object passed a zero rfc3339 day' );
 cmp_ok( $dt0->ymd(), 'eq', $ymd, 'Returned object corrects rfc3339 day 0' );
 
+$dt0 = dt_from_string( '2012-01-01T23:59:00.0Z', 'rfc3339' );
+cmp_ok( $dt0->epoch(), 'eq', '1325462340', 'dt_from_string handles seconds with 1 decimal place' );
+
+$dt0 = dt_from_string( '2012-01-01T23:59:00.00Z', 'rfc3339' );
+cmp_ok( $dt0->epoch(), 'eq', '1325462340', 'dt_from_string handles seconds with 2 decimal places' );
+
+$dt0 = dt_from_string( '2012-01-01T23:59:00.000Z', 'rfc3339' );
+cmp_ok( $dt0->epoch(), 'eq', '1325462340', 'dt_from_string handles seconds with 3 decimal places' );
+
 # Return undef if passed mysql 0 dates
 $dt0 = dt_from_string( '0000-00-00', 'iso' );
 is( $dt0, undef, "undefined returned for 0 iso date" );