Bugzilla – Attachment 58001 Details for
Bug 16376
Koha::Calendar->is_holiday date truncation creates fatal errors for TZ America/Santiago
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16376: (regression tests)
Bug-16376-regression-tests.patch (text/plain), 2.63 KB, created by
Tomás Cohen Arazi (tcohen)
on 2016-12-06 14:40:14 UTC
(
hide
)
Description:
Bug 16376: (regression tests)
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2016-12-06 14:40:14 UTC
Size:
2.63 KB
patch
obsolete
>From 892276e0ee6f1fc0a85554ca1a472d6f49b72fee Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 6 Dec 2016 11:29:08 -0300 >Subject: [PATCH] Bug 16376: (regression tests) > >This patch introduces a regression test for exception_holidays. This routine >returns a list of datetimes to be used in date comparison and some datetimes don't exist >in some timezones, so floating timezones should be used instead. > >To test: >- Apply the patch on master >- Run: > $ prove t/db_dependent/Holidays.t >=> FAIL: The new test fails > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/Holidays.t | 50 +++++++++++++++++++++++++++++++++++++++++++---- > 1 file changed, 46 insertions(+), 4 deletions(-) > >diff --git a/t/db_dependent/Holidays.t b/t/db_dependent/Holidays.t >index 6535535..360bfda 100755 >--- a/t/db_dependent/Holidays.t >+++ b/t/db_dependent/Holidays.t >@@ -17,7 +17,8 @@ > > use Modern::Perl; > >-use Test::More tests => 15; >+use Test::More tests => 16; >+ > use DateTime; > use DateTime::TimeZone; > >@@ -33,11 +34,52 @@ BEGIN { > } > > my $schema = Koha::Database->new->schema; >-$schema->storage->txn_begin; >+my $dbh = C4::Context->dbh; >+my $builder = t::lib::TestBuilder->new; >+ >+subtest 'exception_holidays() tests' => sub { >+ >+ plan tests => 1; >+ >+ $schema->storage->txn_begin; >+ >+ $dbh->do("DELETE FROM special_holidays"); >+ # Clear cache >+ Koha::Caches->get_instance->flush_all; >+ >+ # Artificially set timezone >+ my $timezone = 'America/Santiago'; >+ $ENV{TZ} = $timezone; >+ use POSIX qw(tzset); >+ tzset; >+ >+ my $branch = $builder->build( { source => 'Branch' } )->{branchcode}; >+ my $calendar = Koha::Calendar->new( branchcode => $branch ); > >-my $dbh = C4::Context->dbh(); >+ C4::Calendar->new( branchcode => $branch )->insert_exception_holiday( >+ day => 6, >+ month => 9, >+ year => 2015, >+ title => 'Invalid date', >+ description => 'Invalid date description', >+ ); >+ >+ my $exception_holiday = $calendar->exception_holidays->iterator->next; >+ my $now_dt = DateTime->now; >+ >+ my $diff; >+ eval { $diff = $calendar->days_between( $now_dt, $exception_holiday ) }; >+ unlike( >+ $@, >+ qr/Invalid local time for date in time zone: America\/Santiago/, >+ 'Avoid invalid datetime due to DST' >+ ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+$schema->storage->txn_begin; > >-my $builder = t::lib::TestBuilder->new(); > # Create two fresh branches for the tests > my $branch_1 = $builder->build({ source => 'Branch' })->{ branchcode }; > my $branch_2 = $builder->build({ source => 'Branch' })->{ branchcode }; >-- >2.7.4
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 16376
:
51702
|
51906
|
51968
| 58001 |
58002