Bugzilla – Attachment 166452 Details for
Bug 36486
Add tests for Koha::DateTime::Format::SQL
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36486: Add tests for Koha::DateTime::Format::SQL
Bug-36486-Add-tests-for-KohaDateTimeFormatSQL.patch (text/plain), 2.97 KB, created by
Matt Blenkinsop
on 2024-05-09 10:40:20 UTC
(
hide
)
Description:
Bug 36486: Add tests for Koha::DateTime::Format::SQL
Filename:
MIME Type:
Creator:
Matt Blenkinsop
Created:
2024-05-09 10:40:20 UTC
Size:
2.97 KB
patch
obsolete
>From 90becfb04f296136c29e90ca6d0953fe64af7685 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Tue, 2 Apr 2024 09:34:25 +0200 >Subject: [PATCH] Bug 36486: Add tests for Koha::DateTime::Format::SQL > >Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >--- > t/Koha/DateTime/Format/SQL.t | 84 ++++++++++++++++++++++++++++++++++++ > 1 file changed, 84 insertions(+) > create mode 100644 t/Koha/DateTime/Format/SQL.t > >diff --git a/t/Koha/DateTime/Format/SQL.t b/t/Koha/DateTime/Format/SQL.t >new file mode 100644 >index 0000000000..8ae3f09c54 >--- /dev/null >+++ b/t/Koha/DateTime/Format/SQL.t >@@ -0,0 +1,84 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+use DateTime::TimeZone; >+use Test::Exception; >+use Test::MockModule; >+use Test::More; >+ >+BEGIN { use_ok('Koha::DateTime::Format::SQL'); } >+ >+my $local_timezone = DateTime::TimeZone->new( name => 'local' ); >+my $koha_config_mock = Test::MockModule->new('Koha::Config'); >+my $config = { timezone => '' }; >+$koha_config_mock->mock('get', sub { $config->{$_[1]} }); >+ >+subtest 'normal datetime, no timezone configured' => sub { >+ plan tests => 7; >+ >+ $config->{timezone} = ''; >+ $Koha::DateTime::Format::SQL::timezone = undef; >+ >+ my $dt = Koha::DateTime::Format::SQL->parse_datetime('2024-01-02 10:11:12'); >+ >+ is( $dt->year, 2024 ); >+ is( $dt->month, 1 ); >+ is( $dt->day, 2 ); >+ is( $dt->hour, 10 ); >+ is( $dt->minute, 11 ); >+ is( $dt->second, 12 ); >+ is( $dt->time_zone->name, $local_timezone->name ); >+}; >+ >+subtest 'normal datetime, with timezone configured' => sub { >+ plan tests => 7; >+ >+ $config->{timezone} = 'Pacific/Auckland'; >+ $Koha::DateTime::Format::SQL::timezone = undef; >+ >+ my $dt = Koha::DateTime::Format::SQL->parse_datetime('2024-01-02 10:11:12'); >+ >+ is( $dt->year, 2024 ); >+ is( $dt->month, 1 ); >+ is( $dt->day, 2 ); >+ is( $dt->hour, 10 ); >+ is( $dt->minute, 11 ); >+ is( $dt->second, 12 ); >+ is( $dt->time_zone->name, 'Pacific/Auckland' ); >+}; >+ >+subtest 'infinite datetime, no timezone configured' => sub { >+ plan tests => 7; >+ >+ $config->{timezone} = ''; >+ $Koha::DateTime::Format::SQL::timezone = undef; >+ >+ my $dt = Koha::DateTime::Format::SQL->parse_datetime('9999-01-02 10:11:12'); >+ >+ is( $dt->year, 9999 ); >+ is( $dt->month, 1 ); >+ is( $dt->day, 2 ); >+ is( $dt->hour, 10 ); >+ is( $dt->minute, 11 ); >+ is( $dt->second, 12 ); >+ is( $dt->time_zone->name, 'floating' ); >+}; >+ >+subtest 'normal datetime, with timezone configured' => sub { >+ plan tests => 7; >+ >+ $config->{timezone} = 'Pacific/Auckland'; >+ $Koha::DateTime::Format::SQL::timezone = undef; >+ >+ my $dt = Koha::DateTime::Format::SQL->parse_datetime('9999-01-02 10:11:12'); >+ >+ is( $dt->year, 9999 ); >+ is( $dt->month, 1 ); >+ is( $dt->day, 2 ); >+ is( $dt->hour, 10 ); >+ is( $dt->minute, 11 ); >+ is( $dt->second, 12 ); >+ is( $dt->time_zone->name, 'floating' ); >+}; >+ >+done_testing; >-- >2.37.1 (Apple Git-137.1)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36486
:
164235
|
166452
|
166508
|
166511
|
166512