Bugzilla – Attachment 83188 Details for
Bug 21824
Add ability to format dates in various formats in templates
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21824: Add tests
Bug-21824-Add-tests.patch (text/plain), 2.68 KB, created by
Jonathan Druart
on 2018-12-13 21:24:56 UTC
(
hide
)
Description:
Bug 21824: Add tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-12-13 21:24:56 UTC
Size:
2.68 KB
patch
obsolete
>From af558114a843b1f6bd1a3cb3b8aec76d833b3681 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 13 Dec 2018 18:24:32 -0300 >Subject: [PATCH] Bug 21824: Add tests > >--- > t/db_dependent/Letters/TemplateToolkit.t | 53 +++++++++++++++++++++++++++++++- > 1 file changed, 52 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Letters/TemplateToolkit.t b/t/db_dependent/Letters/TemplateToolkit.t >index 2714317458..4fe113e0a6 100644 >--- a/t/db_dependent/Letters/TemplateToolkit.t >+++ b/t/db_dependent/Letters/TemplateToolkit.t >@@ -19,13 +19,14 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 18; >+use Test::More tests => 19; > use Test::MockModule; > use Test::Warn; > > use MARC::Record; > > use t::lib::TestBuilder; >+use t::lib::Mocks; > > use C4::Circulation; > use C4::Letters; >@@ -1060,6 +1061,56 @@ subtest 'add_tt_filters' => sub { > is( $letter->{content}, $expected_letter, "Pre-processing should call TT plugin to remove punctuation if table is biblio or biblioitems"); > }; > >+subtest 'Dates formatting' => sub { >+ plan tests => 1; >+ my $code = 'TEST_DATE'; >+ t::lib::Mocks::mock_preference('dateformat', 'metric'); # MM/DD/YYYY >+ my $biblio = $builder->build_object( >+ { >+ class => 'Koha::Biblios', >+ value => { >+ timestamp => '2018-12-13 20:21:22', >+ datecreated => '2018-12-13' >+ } >+ } >+ ); >+ my $template = <<EOF; >+[%- USE KohaDates -%] >+[% biblio.timestamp %] >+[% biblio.timestamp | \$KohaDates %] >+[% biblio.timestamp | \$KohaDates with_hours => 1 %] >+ >+[% biblio.datecreated %] >+[% biblio.datecreated | \$KohaDates %] >+[% biblio.datecreated | \$KohaDates with_hours => 1 %] >+ >+[% biblio.timestamp | \$KohaDates dateformat => 'iso' %] >+[% KohaDates.output_preference( str => biblio.timestamp, dateformat => 'iso' ) %] >+[% KohaDates.output_preference( str => biblio.timestamp, dateformat => 'iso', dateonly => 1 ) %] >+EOF >+ reset_template({ template => $template, code => $code, module => 'test' }); >+ my $letter = GetPreparedLetter( >+ module => 'test', >+ letter_code => $code, >+ tables => { >+ biblio => $biblio->biblionumber, >+ } >+ ); >+ my $expected_content = sprintf("%s\n%s\n%s\n\n%s\n%s\n%s\n\n%s\n%s\n%s\n", >+ '2018-12-13 20:21:22', >+ '13/12/2018', >+ '13/12/2018 20:21', >+ >+ '2018-12-13', >+ '13/12/2018', >+ '13/12/2018 00:00', >+ >+ '2018-12-13', >+ '2018-12-13 20:21', >+ '2018-12-13', >+ ); >+ is( $letter->{content}, $expected_content ); >+}; > > sub reset_template { > my ( $params ) = @_; >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21824
:
82308
|
82316
|
82879
|
82880
|
83188
|
91354
|
91355
|
91356
|
91357
|
91358
|
91363
|
91364
|
94920
|
94921
|
94922