Bug 7359 - Begin migration to a new "Koha" namespace from the old "C4" namespace
[koha.git] / t / Koha_template_plugin_KohaDates.t
1 #!/usr/bin/perl
2 #
3
4 use strict;
5 use warnings;
6 use C4::Context;
7 use C4::Dates;
8 use Test::More tests => 5;
9
10 BEGIN {
11         use_ok('Koha::Template::Plugin::KohaDates');
12 }
13
14 my $date = "1973-05-21";
15 my $context = C4::Context->new();
16 my $dateobj = C4::Dates->new();
17
18 my $filter = Koha::Template::Plugin::KohaDates->new();
19 ok ($filter, "new()");
20
21
22 $context->set_preference( "dateformat", 'iso' );
23 $context->clear_syspref_cache();
24 $dateobj->reset_prefformat;
25
26 my $filtered_date = $filter->filter($date);
27 is ($filtered_date,$date, "iso conversion") or diag ("iso conversion fails");
28
29 #$filter = Koha::Template::Plugin::KohaDates->new();
30 $context->set_preference( "dateformat", 'us' );
31 $context->clear_syspref_cache();
32 $dateobj->reset_prefformat;
33
34 $filtered_date = $filter->filter($date);
35 is ($filtered_date,'05/21/1973', "us conversion") or diag ("us conversion fails $filtered_date");
36
37 $context->set_preference( "dateformat", 'metric' );
38 $context->clear_syspref_cache();
39 $dateobj->reset_prefformat;
40
41 $filtered_date = $filter->filter($date);
42 is ($filtered_date,'21/05/1973', "metric conversion") or diag ("metric conversion fails $filtered_date");