Bugzilla – Attachment 91354 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.62 KB, created by
Bouzid Fergani
on 2019-07-05 18:26:49 UTC
(
hide
)
Description:
Bug 21824: Add tests
Filename:
MIME Type:
Creator:
Bouzid Fergani
Created:
2019-07-05 18:26:49 UTC
Size:
2.62 KB
patch
obsolete
>From 37da3a728286802842a6ea09119e70db5877bb41 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 > >Signed-off-by: Bouzid Fergani <bouzid.fergani@inlibro.com> >--- > t/db_dependent/Letters/TemplateToolkit.t | 52 +++++++++++++++++++++++++++++++- > 1 file changed, 51 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Letters/TemplateToolkit.t b/t/db_dependent/Letters/TemplateToolkit.t >index 502e429..b8bc95c 100644 >--- a/t/db_dependent/Letters/TemplateToolkit.t >+++ b/t/db_dependent/Letters/TemplateToolkit.t >@@ -19,7 +19,7 @@ > # 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; > >@@ -1060,6 +1060,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.7.4
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