Koha/t/Date.t
Galen Charlton 5290ec5596 test suite cleanup
Many of the tests were failing or putting warnings
because a valid systempreferences table is
usaully absent by the time 'make test' is run.

Fortunately, only a few modules try to invoke
C4::Context->preference during module initialization,
so added to the test suite override_context_prefs.pm,
which replaces preference() with a sub to return
testing values for three variables: 'dateformat',
'marcflavour', and 'LibraryName'.

Also fixed bug in t/Boolean.t

With this patch and the patch to move the DB-dependent
tests off to the side for the moment, 'make test'
now runs cleanly, at least on Debian.

Signed-off-by: Chris Cormack <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
2008-01-08 14:08:02 -06:00

49 lines
1,013 B
Perl
Executable file

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');
}