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

(-)a/t/db_dependent/Letters/TemplateToolkit.t (-2 / +52 lines)
Lines 19-31 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
26
use MARC::Record;
26
use MARC::Record;
27
27
28
use t::lib::TestBuilder;
28
use t::lib::TestBuilder;
29
use t::lib::Mocks;
29
30
30
use C4::Circulation;
31
use C4::Circulation;
31
use C4::Letters;
32
use C4::Letters;
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");
1061
    is( $letter->{content}, $expected_letter, "Pre-processing should call TT plugin to remove punctuation if table is biblio or biblioitems");
1061
};
1062
};
1062
1063
1064
subtest 'Dates formatting' => sub {
1065
    plan tests => 1;
1066
    my $code = 'TEST_DATE';
1067
    t::lib::Mocks::mock_preference('dateformat', 'metric'); # MM/DD/YYYY
1068
    my $biblio = $builder->build_object(
1069
        {
1070
            class => 'Koha::Biblios',
1071
            value => {
1072
                timestamp   => '2018-12-13 20:21:22',
1073
                datecreated => '2018-12-13'
1074
            }
1075
        }
1076
    );
1077
    my $template = <<EOF;
1078
[%- USE KohaDates -%]
1079
[% biblio.timestamp %]
1080
[% biblio.timestamp | \$KohaDates %]
1081
[% biblio.timestamp | \$KohaDates with_hours => 1 %]
1082
1083
[% biblio.datecreated %]
1084
[% biblio.datecreated | \$KohaDates %]
1085
[% biblio.datecreated | \$KohaDates with_hours => 1 %]
1086
1087
[% biblio.timestamp | \$KohaDates dateformat => 'iso' %]
1088
[% KohaDates.output_preference( str => biblio.timestamp, dateformat => 'iso' ) %]
1089
[% KohaDates.output_preference( str => biblio.timestamp, dateformat => 'iso', dateonly => 1 ) %]
1090
EOF
1091
    reset_template({ template => $template, code => $code, module => 'test' });
1092
    my $letter = GetPreparedLetter(
1093
        module => 'test',
1094
        letter_code => $code,
1095
        tables => {
1096
            biblio => $biblio->biblionumber,
1097
        }
1098
    );
1099
    my $expected_content = sprintf("%s\n%s\n%s\n\n%s\n%s\n%s\n\n%s\n%s\n%s\n",
1100
        '2018-12-13 20:21:22',
1101
        '13/12/2018',
1102
        '13/12/2018 20:21',
1103
1104
        '2018-12-13',
1105
        '13/12/2018',
1106
        '13/12/2018 00:00',
1107
1108
        '2018-12-13',
1109
        '2018-12-13 20:21',
1110
        '2018-12-13',
1111
    );
1112
    is( $letter->{content}, $expected_content );
1113
};
1063
1114
1064
sub reset_template {
1115
sub reset_template {
1065
    my ( $params ) = @_;
1116
    my ( $params ) = @_;
1066
- 

Return to bug 21824