Bugzilla – Attachment 7110 Details for
Bug 929
See details of a budget
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 929 : Follow up adding unit tests, discovered C4::Dates cached the syspref with no way to clear it, fixed also.
Bug-929--Follow-up-adding-unit-tests-discovered-C4.patch (text/plain), 2.36 KB, created by
Chris Cormack
on 2012-01-12 08:25:25 UTC
(
hide
)
Description:
Bug 929 : Follow up adding unit tests, discovered C4::Dates cached the syspref with no way to clear it, fixed also.
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2012-01-12 08:25:25 UTC
Size:
2.36 KB
patch
obsolete
>From 6432ed8f5e757115efc5defa742a308c09895844 Mon Sep 17 00:00:00 2001 >From: Chris Cormack <chrisc@catalyst.net.nz> >Date: Thu, 12 Jan 2012 21:23:21 +1300 >Subject: [PATCH] Bug 929 : Follow up adding unit tests, discovered C4::Dates > cached the syspref with no way to clear it, fixed also. > >--- > C4/Dates.pm | 6 +++++ > t/Koha_template_plugin_KohaDates.t | 42 ++++++++++++++++++++++++++++++++++++ > 2 files changed, 48 insertions(+), 0 deletions(-) > create mode 100644 t/Koha_template_plugin_KohaDates.t > >diff --git a/C4/Dates.pm b/C4/Dates.pm >index e61fc19..50db12e 100644 >--- a/C4/Dates.pm >+++ b/C4/Dates.pm >@@ -41,6 +41,12 @@ sub _prefformat { > return $prefformat; > } > >+sub reset_prefformat { # subroutine to clear the prefformat, called when we change it >+ if (defined $prefformat){ >+ $prefformat = C4::Context->preference('dateformat'); >+ } >+} >+ > our %format_map = ( > iso => 'yyyy-mm-dd', # plus " HH:MM:SS" > metric => 'dd/mm/yyyy', # plus " HH:MM:SS" >diff --git a/t/Koha_template_plugin_KohaDates.t b/t/Koha_template_plugin_KohaDates.t >new file mode 100644 >index 0000000..f9a0e72 >--- /dev/null >+++ b/t/Koha_template_plugin_KohaDates.t >@@ -0,0 +1,42 @@ >+#!/usr/bin/perl >+# >+ >+use strict; >+use warnings; >+use C4::Context; >+use C4::Dates; >+use Test::More tests => 5; >+ >+BEGIN { >+ use_ok('Koha::Template::Plugin::KohaDates'); >+} >+ >+my $date = "1973-05-21"; >+my $context = C4::Context->new(); >+my $dateobj = C4::Dates->new(); >+ >+my $filter = Koha::Template::Plugin::KohaDates->new(); >+ok ($filter, "new()"); >+ >+ >+$context->set_preference( "dateformat", 'iso' ); >+$context->clear_syspref_cache(); >+$dateobj->reset_prefformat; >+ >+my $filtered_date = $filter->filter($date); >+is ($filtered_date,$date, "iso conversion") or diag ("iso conversion fails"); >+ >+#$filter = Koha::Template::Plugin::KohaDates->new(); >+$context->set_preference( "dateformat", 'us' ); >+$context->clear_syspref_cache(); >+$dateobj->reset_prefformat; >+ >+$filtered_date = $filter->filter($date); >+is ($filtered_date,'05/21/1973', "us conversion") or diag ("us conversion fails $filtered_date"); >+ >+$context->set_preference( "dateformat", 'metric' ); >+$context->clear_syspref_cache(); >+$dateobj->reset_prefformat; >+ >+$filtered_date = $filter->filter($date); >+is ($filtered_date,'21/05/1973', "metric conversion") or diag ("metric conversion fails $filtered_date"); >-- >1.7.5.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 929
:
6936
|
6941
|
6947
|
6948
|
6949
|
6950
|
6951
|
6952
|
6953
|
6958
|
7109
|
7110
|
7142
|
7143
|
7393