Bug 24850: (follow-up) Add tests for invalid RFC3339 dates

Make this failure explicit, otherwise we get a "bad plan" failure.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2021-02-08 15:46:35 +01:00
parent b246e6de1b
commit afa594c73b
1 changed files with 2 additions and 4 deletions

View File

@ -137,12 +137,10 @@ cmp_ok( $dt0->epoch(), 'eq', '1325462399', 'dt_from_string handles seconds with
$dt0 = dt_from_string( '2012-01-01T23:59:59.999+02:00', 'rfc3339' );
cmp_ok( $dt0->epoch(), 'eq', '1325455199', 'dt_from_string handles seconds with 3 decimal places and a timezone' );
try {
eval {
$dt0 = dt_from_string( '2012-01-01T23:59:59.999Z+02:00', 'rfc3339' );
}
catch {
like( $_, qr/.*does not match the date format \(rfc3339\).*/, 'dt_from_string should die when passed a bad date string' );
};
like( $@, qr/.*does not match the date format \(rfc3339\).*/, 'dt_from_string should die when passed a bad date string' );
# Return undef if passed mysql 0 dates
$dt0 = dt_from_string( '0000-00-00', 'iso' );