Lines 3-9
use DateTime;
Link Here
|
3 |
use DateTime::TimeZone; |
3 |
use DateTime::TimeZone; |
4 |
|
4 |
|
5 |
use C4::Context; |
5 |
use C4::Context; |
6 |
use Test::More tests => 58; |
6 |
use Test::More tests => 59; |
7 |
use Test::MockModule; |
7 |
use Test::MockModule; |
8 |
use Test::Warn; |
8 |
use Test::Warn; |
9 |
use Time::HiRes qw/ gettimeofday /; |
9 |
use Time::HiRes qw/ gettimeofday /; |
Lines 218-226
$dt = dt_from_string('2015-01-31 01:02:03');
Link Here
|
218 |
is( output_pref( {dt => $dt} ), '31/01/2015 01:02', 'dt_from_string should fallback to sql format' ); |
218 |
is( output_pref( {dt => $dt} ), '31/01/2015 01:02', 'dt_from_string should fallback to sql format' ); |
219 |
|
219 |
|
220 |
# output_pref with str parameter |
220 |
# output_pref with str parameter |
221 |
is( output_pref( { 'str' => $testdate_iso, dateformat => 'iso', dateonly => 1 } ), $testdate_iso, 'output_pref should handle correctly the iso parameter' ); |
221 |
is( output_pref( { 'str' => $testdate_iso, dateformat => 'iso', dateonly => 1 } ), $testdate_iso, 'output_pref should handle correctly the iso parameter' ); |
222 |
is( output_pref( { 'str' => 'invalid_date', dateformat => 'iso', dateonly => 1 } ), undef, 'output_pref should return undef if an invalid date is passed' ); |
222 |
my $output_for_invalid_date; |
|
|
223 |
warning_like { $output_for_invalid_date = output_pref( { str => 'invalid_date' } ) } |
224 |
{ carped => qr[^Invalid date 'invalid_date' passed to output_pref] }, |
225 |
'output_pref should carp if an invalid date is passed for the str parameter'; |
226 |
is( $output_for_invalid_date, undef, 'output_pref should return undef if an invalid date is passed' ); |
223 |
warning_is { output_pref( { 'str' => $testdate_iso, dt => $dt, dateformat => 'iso', dateonly => 1 } ) } |
227 |
warning_is { output_pref( { 'str' => $testdate_iso, dt => $dt, dateformat => 'iso', dateonly => 1 } ) } |
224 |
{ carped => 'output_pref should not be called with both dt and str parameters' }, |
228 |
{ carped => 'output_pref should not be called with both dt and str parameters' }, |
225 |
'output_pref should carp if str and dt parameters are passed together'; |
229 |
'output_pref should carp if str and dt parameters are passed together'; |
226 |
|
|
|
227 |
- |