Bugzilla – Attachment 44780 Details for
Bug 15166
Make output_pref accept a string as parameter
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 15166: Carp if an invalid date is passed
PASSED-QA-Bug-15166-Carp-if-an-invalid-date-is-pas.patch (text/plain), 2.57 KB, created by
Katrin Fischer
on 2015-11-11 22:08:22 UTC
(
hide
)
Description:
[PASSED QA] Bug 15166: Carp if an invalid date is passed
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2015-11-11 22:08:22 UTC
Size:
2.57 KB
patch
obsolete
>From b2b3bf7b0daf467bf408d27b94d42192919b2de2 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 11 Nov 2015 11:55:05 +0000 >Subject: [PATCH] [PASSED QA] Bug 15166: Carp if an invalid date is passed >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Sign-off on second patch. >Signed-off-by: Marc Véron <veron@veron.ch> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > Koha/DateUtils.pm | 1 + > t/DateUtils.t | 10 +++++++--- > 2 files changed, 8 insertions(+), 3 deletions(-) > >diff --git a/Koha/DateUtils.pm b/Koha/DateUtils.pm >index ca2ede5..e2e8cfc 100644 >--- a/Koha/DateUtils.pm >+++ b/Koha/DateUtils.pm >@@ -205,6 +205,7 @@ sub output_pref { > if $dt and $str; > > $dt = eval { dt_from_string( $str ) } if $str; >+ carp "Invalid date '$str' passed to output_pref\n" if $@; > > return unless defined $dt; > >diff --git a/t/DateUtils.t b/t/DateUtils.t >index 0dd749b..ca60372 100755 >--- a/t/DateUtils.t >+++ b/t/DateUtils.t >@@ -3,7 +3,7 @@ use DateTime; > use DateTime::TimeZone; > > use C4::Context; >-use Test::More tests => 58; >+use Test::More tests => 59; > use Test::MockModule; > use Test::Warn; > use Time::HiRes qw/ gettimeofday /; >@@ -218,8 +218,12 @@ $dt = dt_from_string('2015-01-31 01:02:03'); > is( output_pref( {dt => $dt} ), '31/01/2015 01:02', 'dt_from_string should fallback to sql format' ); > > # output_pref with str parameter >-is( output_pref( { 'str' => $testdate_iso, dateformat => 'iso', dateonly => 1 } ), $testdate_iso, 'output_pref should handle correctly the iso parameter' ); >-is( output_pref( { 'str' => 'invalid_date', dateformat => 'iso', dateonly => 1 } ), undef, 'output_pref should return undef if an invalid date is passed' ); >+is( output_pref( { 'str' => $testdate_iso, dateformat => 'iso', dateonly => 1 } ), $testdate_iso, 'output_pref should handle correctly the iso parameter' ); >+my $output_for_invalid_date; >+warning_like { $output_for_invalid_date = output_pref( { str => 'invalid_date' } ) } >+ { carped => qr[^Invalid date 'invalid_date' passed to output_pref] }, >+ 'output_pref should carp if an invalid date is passed for the str parameter'; >+is( $output_for_invalid_date, undef, 'output_pref should return undef if an invalid date is passed' ); > warning_is { output_pref( { 'str' => $testdate_iso, dt => $dt, dateformat => 'iso', dateonly => 1 } ) } > { carped => 'output_pref should not be called with both dt and str parameters' }, > 'output_pref should carp if str and dt parameters are passed together'; >-- >1.9.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 15166
:
44716
|
44721
|
44738
|
44744
|
44779
| 44780