Lines 1-16
Link Here
|
1 |
use Modern::Perl; |
1 |
use Modern::Perl; |
2 |
|
2 |
|
3 |
use Test::More tests => 28; |
3 |
use Test::More tests => 30; |
4 |
|
4 |
|
5 |
use Test::MockModule; |
5 |
use Test::MockModule; |
6 |
use t::lib::Mocks; |
6 |
use t::lib::Mocks; |
7 |
|
7 |
|
|
|
8 |
# Number formating depends by default on system environement |
9 |
# See http://search.cpan.org/~wrw/Number-Format/Format.pm |
10 |
use POSIX qw(setlocale LC_NUMERIC); |
11 |
|
8 |
use Koha::Acquisition::Currencies; |
12 |
use Koha::Acquisition::Currencies; |
9 |
my $budget_module = Test::MockModule->new('Koha::Acquisition::Currencies'); |
13 |
my $budget_module = Test::MockModule->new('Koha::Acquisition::Currencies'); |
10 |
my $currency; |
14 |
my $currency; |
11 |
$budget_module->mock( 'get_active', sub { return $currency; } ); |
15 |
$budget_module->mock( 'get_active', sub { return $currency; } ); |
12 |
use_ok('Koha::Number::Price'); |
16 |
use_ok('Koha::Number::Price'); |
13 |
|
17 |
|
|
|
18 |
my $orig_locale = setlocale(LC_NUMERIC); |
14 |
my $format = { |
19 |
my $format = { |
15 |
p_cs_precedes => 1, # Force to place the symbol at the beginning |
20 |
p_cs_precedes => 1, # Force to place the symbol at the beginning |
16 |
p_sep_by_space => 0, # Force to not add a space between the symbol and the number |
21 |
p_sep_by_space => 0, # Force to not add a space between the symbol and the number |
Lines 44-49
is( Koha::Number::Price->new(3)->unformat, '3', 'US: unformat 3' );
Link Here
|
44 |
is( Koha::Number::Price->new(1234567890)->unformat, |
49 |
is( Koha::Number::Price->new(1234567890)->unformat, |
45 |
'1234567890', 'US: unformat 1234567890' ); |
50 |
'1234567890', 'US: unformat 1234567890' ); |
46 |
|
51 |
|
|
|
52 |
# Bug 18900 - Check params are not from system environement |
53 |
setlocale(LC_NUMERIC, "fr_FR.UTF-8"); |
54 |
is( Koha::Number::Price->new(12345678.9)->format( { %$format, with_symbol => 1 } ), |
55 |
'12,345,678.90', 'US: format 12,345,678.90 with symbol' ); |
56 |
is( Koha::Number::Price->new('12,345,678.90')->unformat, |
57 |
'12345678.9', 'US: unformat 12345678.9' ); |
58 |
setlocale(LC_NUMERIC, $orig_locale); |
59 |
|
47 |
t::lib::Mocks::mock_preference( 'CurrencyFormat', 'FR' ); |
60 |
t::lib::Mocks::mock_preference( 'CurrencyFormat', 'FR' ); |
48 |
$currency = Koha::Acquisition::Currency->new({ |
61 |
$currency = Koha::Acquisition::Currency->new({ |
49 |
currency => 'EUR', |
62 |
currency => 'EUR', |
50 |
- |
|
|