View | Details | Raw Unified | Return to bug 21824
Collapse All | Expand All

(-)a/t/db_dependent/Letters/TemplateToolkit.t (-2 / +51 lines)
Lines 19-25 Link Here
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
20
20
21
use Modern::Perl;
21
use Modern::Perl;
22
use Test::More tests => 18;
22
use Test::More tests => 19;
23
use Test::MockModule;
23
use Test::MockModule;
24
use Test::Warn;
24
use Test::Warn;
25
25
Lines 1060-1065 subtest 'add_tt_filters' => sub { Link Here
1060
    is( $letter->{content}, $expected_letter, "Pre-processing should call TT plugin to remove punctuation if table is biblio or biblioitems");
1060
    is( $letter->{content}, $expected_letter, "Pre-processing should call TT plugin to remove punctuation if table is biblio or biblioitems");
1061
};
1061
};
1062
1062
1063
subtest 'Dates formatting' => sub {
1064
    plan tests => 1;
1065
    my $code = 'TEST_DATE';
1066
    t::lib::Mocks::mock_preference('dateformat', 'metric'); # MM/DD/YYYY
1067
    my $biblio = $builder->build_object(
1068
        {
1069
            class => 'Koha::Biblios',
1070
            value => {
1071
                timestamp   => '2018-12-13 20:21:22',
1072
                datecreated => '2018-12-13'
1073
            }
1074
        }
1075
    );
1076
    my $template = <<EOF;
1077
[%- USE KohaDates -%]
1078
[% biblio.timestamp %]
1079
[% biblio.timestamp | \$KohaDates %]
1080
[% biblio.timestamp | \$KohaDates with_hours => 1 %]
1081
1082
[% biblio.datecreated %]
1083
[% biblio.datecreated | \$KohaDates %]
1084
[% biblio.datecreated | \$KohaDates with_hours => 1 %]
1085
1086
[% biblio.timestamp | \$KohaDates dateformat => 'iso' %]
1087
[% KohaDates.output_preference( str => biblio.timestamp, dateformat => 'iso' ) %]
1088
[% KohaDates.output_preference( str => biblio.timestamp, dateformat => 'iso', dateonly => 1 ) %]
1089
EOF
1090
    reset_template({ template => $template, code => $code, module => 'test' });
1091
    my $letter = GetPreparedLetter(
1092
        module => 'test',
1093
        letter_code => $code,
1094
        tables => {
1095
            biblio => $biblio->biblionumber,
1096
        }
1097
    );
1098
    my $expected_content = sprintf("%s\n%s\n%s\n\n%s\n%s\n%s\n\n%s\n%s\n%s\n",
1099
        '2018-12-13 20:21:22',
1100
        '13/12/2018',
1101
        '13/12/2018 20:21',
1102
1103
        '2018-12-13',
1104
        '13/12/2018',
1105
        '13/12/2018 00:00',
1106
1107
        '2018-12-13',
1108
        '2018-12-13 20:21',
1109
        '2018-12-13',
1110
    );
1111
    is( $letter->{content}, $expected_content );
1112
};
1063
1113
1064
sub reset_template {
1114
sub reset_template {
1065
    my ( $params ) = @_;
1115
    my ( $params ) = @_;
1066
- 

Return to bug 21824