Bugzilla – Attachment 32318 Details for
Bug 12844
Introduce a centralized way to display prices
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 12844: Force the symbol place in the tests
PASSED-QA-Bug-12844-Force-the-symbol-place-in-the-.patch (text/plain), 4.47 KB, created by
Katrin Fischer
on 2014-10-14 14:18:33 UTC
(
hide
)
Description:
[PASSED QA] Bug 12844: Force the symbol place in the tests
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2014-10-14 14:18:33 UTC
Size:
4.47 KB
patch
obsolete
>From bd0e1bdece38c52e6afa00dcf34712a0c081eb8e Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Fri, 10 Oct 2014 22:47:32 +0200 >Subject: [PATCH] [PASSED QA] Bug 12844: Force the symbol place in the tests > >Looking with Katrin at the default configuration of Number::Format, she >has the p_cs_precedes value set to 0 (put the symbol at the end) and >p_sep_by_sep set to 1. > >Now it is possible to sent these values to the format subroutine. >On this way, the tests can force them in order to pass on all configuration. > >This default value for this variable certainly depends on the locales. > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > Koha/Number/Price.pm | 5 +++++ > t/Number/Price.t | 28 ++++++++++++++++------------ > 2 files changed, 21 insertions(+), 12 deletions(-) > >diff --git a/Koha/Number/Price.pm b/Koha/Number/Price.pm >index 2fb9c54..80854ab 100644 >--- a/Koha/Number/Price.pm >+++ b/Koha/Number/Price.pm >@@ -56,6 +56,8 @@ sub unformat { > sub _format_params { > my ( $self, $params ) = @_; > my $with_symbol = $params->{with_symbol} || 0; >+ my $p_cs_precedes = $params->{p_cs_precedes}; >+ my $p_sep_by_space = $params->{p_sep_by_space}; > my $currency = GetCurrency(); > my $currency_format = C4::Context->preference("CurrencyFormat"); > >@@ -79,6 +81,9 @@ sub _format_params { > ); > } > >+ $format_params{p_cs_precedes} = $p_cs_precedes if defined $p_cs_precedes; >+ $format_params{p_sep_by_space} = $p_sep_by_space if defined $p_sep_by_space; >+ > return \%format_params; > } > >diff --git a/t/Number/Price.t b/t/Number/Price.t >index edb6d53..3191e4d 100644 >--- a/t/Number/Price.t >+++ b/t/Number/Price.t >@@ -11,6 +11,10 @@ my $currency; > $budget_module->mock( 'GetCurrency', sub { return $currency; } ); > use_ok('Koha::Number::Price'); > >+my $format = { >+ p_cs_precedes => 1, # Force to place the symbol at the beginning >+ p_sep_by_space => 0, # Force to not add a space between the symbol and the number >+}; > t::lib::Mocks::mock_preference( 'CurrencyFormat', 'US' ); > $currency = { > currency => 'USD', >@@ -19,19 +23,19 @@ $currency = { > active => 1, > }; > >-is( Koha::Number::Price->new->format, '0.00', 'US: format 0' ); >-is( Koha::Number::Price->new(3)->format, '3.00', 'US: format 3' ); >-is( Koha::Number::Price->new(1234567890)->format, >+is( Koha::Number::Price->new->format( $format ), '0.00', 'US: format 0' ); >+is( Koha::Number::Price->new(3)->format( $format ), '3.00', 'US: format 3' ); >+is( Koha::Number::Price->new(1234567890)->format( $format ), > '1,234,567,890.00', 'US: format 1234567890' ); > > # FIXME This should be display symbol, but it was the case before the creation of this module >-is( Koha::Number::Price->new->format( { with_symbol => 1 } ), >+is( Koha::Number::Price->new->format( { %$format, with_symbol => 1 } ), > '0.00', 'US: format 0 with symbol' ); >-is( Koha::Number::Price->new(3)->format( { with_symbol => 1 } ), >+is( Koha::Number::Price->new(3)->format( { %$format, with_symbol => 1 } ), > '3.00', 'US: format 3 with symbol' ); > is( > Koha::Number::Price->new(1234567890) >- ->format( { with_symbol => 1 }, 'US: format 1234567890 with symbol' ), >+ ->format( { %$format, with_symbol => 1 }, 'US: format 1234567890 with symbol' ), > '1,234,567,890.00' > ); > >@@ -50,20 +54,20 @@ $currency = { > > # Actually,the price formating for France is 3,00⬠> # How put the symbol at the end with Number::Format? >-is( Koha::Number::Price->new->format, '0,00', 'FR: format 0' ); >-is( Koha::Number::Price->new(3)->format, '3,00', 'FR: format 3' ); >+is( Koha::Number::Price->new->format( $format ), '0,00', 'FR: format 0' ); >+is( Koha::Number::Price->new(3)->format( $format ), '3,00', 'FR: format 3' ); > is( >- Koha::Number::Price->new(1234567890)->format, >+ Koha::Number::Price->new(1234567890)->format( $format ), > '1 234 567 890,00', > 'FR: format 1234567890' > ); >-is( Koha::Number::Price->new->format( { with_symbol => 1 } ), >+is( Koha::Number::Price->new->format( { %$format, with_symbol => 1 } ), > 'â¬0,00', 'FR: format 0 with symbol' ); >-is( Koha::Number::Price->new(3)->format( { with_symbol => 1 } ), >+is( Koha::Number::Price->new(3)->format( { %$format, with_symbol => 1 } ), > 'â¬3,00', 'FR: format 3 with symbol' ); > is( > Koha::Number::Price->new(1234567890) >- ->format( { with_symbol => 1 }, 'FR: format 123567890 with symbol' ), >+ ->format( { %$format, with_symbol => 1 }, 'FR: format 123567890 with symbol' ), > 'â¬1 234 567 890,00' > ); > >-- >1.9.1
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 12844
:
31258
|
31259
|
31260
|
31304
|
31618
|
31624
|
31625
|
31626
|
31627
|
31813
|
31826
|
32211
|
32229
|
32314
|
32315
|
32316
|
32317
| 32318