X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;ds=sidebyside;f=t%2FDate.t;h=28c32b2635dae0f7c4f6866276adf241a25f0ad2;hb=d6f2a2ef9c8eb289908737fa4a58bde1d0b5d5eb;hp=56b7cbc55201edd7cd17cd39ab12e5a393b81997;hpb=77618f43cf589c5dddcf5ad13f8afda51d1a1129;p=koha.git diff --git a/t/Date.t b/t/Date.t old mode 100644 new mode 100755 index 56b7cbc552..28c32b2635 --- a/t/Date.t +++ b/t/Date.t @@ -1,5 +1,49 @@ -BEGIN { $| = 1; print "1..1\n"; } -END {print "not ok 1\n" unless $loaded;} -use C4::Date; -$loaded = 1; -print "ok 1\n"; +print "WARNING: This module (C4::Date) is obsolete. +Developers should use C4::Dates instead!\n"; + +use strict; +use warnings; + +use Test::More tests => 4; + +BEGIN { + use FindBin; + use lib $FindBin::Bin; + use override_context_prefs; + use_ok('C4::Date'); +} + +# testing format_date_in_iso +my $format= display_date_format (); +my $date; +my $invaliddate; +if ($format eq 'mm/dd/yyyy'){ + $date = '05/21/1973'; +} +elsif ($format eq 'dd/mm/yyyy'){ + $date = '21/05/1973'; +} +elsif ($format eq 'yyyy-mm-dd'){ + $date = '1973-05-21'; +} +$date=format_date_in_iso($date); +is($date, '1973-05-21', 'format_date_in_iso'); + +# test format date +$date=format_date($date); +if ($format eq 'mm/dd/yyyy'){ + is($date, '05/21/1973', 'format_date'); +} +elsif ($format eq 'dd/mm/yyyy'){ + is($date, '21/05/1973', 'format_date'); +} +elsif ($format eq 'yyyy-mm-dd'){ + is($date, '1973-05-21', 'format_date'); +} + +# test 4 fixdate + +($date,$invaliddate) = fixdate('2007','06','31'); +if ($invaliddate){ + ok($invaliddate, 'fixdate'); +}