Lines 11-16
my $currency;
Link Here
|
11 |
$budget_module->mock( 'GetCurrency', sub { return $currency; } ); |
11 |
$budget_module->mock( 'GetCurrency', sub { return $currency; } ); |
12 |
use_ok('Koha::Number::Price'); |
12 |
use_ok('Koha::Number::Price'); |
13 |
|
13 |
|
|
|
14 |
my $format = { |
15 |
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 |
17 |
}; |
14 |
t::lib::Mocks::mock_preference( 'CurrencyFormat', 'US' ); |
18 |
t::lib::Mocks::mock_preference( 'CurrencyFormat', 'US' ); |
15 |
$currency = { |
19 |
$currency = { |
16 |
currency => 'USD', |
20 |
currency => 'USD', |
Lines 19-37
$currency = {
Link Here
|
19 |
active => 1, |
23 |
active => 1, |
20 |
}; |
24 |
}; |
21 |
|
25 |
|
22 |
is( Koha::Number::Price->new->format, '0.00', 'US: format 0' ); |
26 |
is( Koha::Number::Price->new->format( $format ), '0.00', 'US: format 0' ); |
23 |
is( Koha::Number::Price->new(3)->format, '3.00', 'US: format 3' ); |
27 |
is( Koha::Number::Price->new(3)->format( $format ), '3.00', 'US: format 3' ); |
24 |
is( Koha::Number::Price->new(1234567890)->format, |
28 |
is( Koha::Number::Price->new(1234567890)->format( $format ), |
25 |
'1,234,567,890.00', 'US: format 1234567890' ); |
29 |
'1,234,567,890.00', 'US: format 1234567890' ); |
26 |
|
30 |
|
27 |
# FIXME This should be display symbol, but it was the case before the creation of this module |
31 |
# FIXME This should be display symbol, but it was the case before the creation of this module |
28 |
is( Koha::Number::Price->new->format( { with_symbol => 1 } ), |
32 |
is( Koha::Number::Price->new->format( { %$format, with_symbol => 1 } ), |
29 |
'0.00', 'US: format 0 with symbol' ); |
33 |
'0.00', 'US: format 0 with symbol' ); |
30 |
is( Koha::Number::Price->new(3)->format( { with_symbol => 1 } ), |
34 |
is( Koha::Number::Price->new(3)->format( { %$format, with_symbol => 1 } ), |
31 |
'3.00', 'US: format 3 with symbol' ); |
35 |
'3.00', 'US: format 3 with symbol' ); |
32 |
is( |
36 |
is( |
33 |
Koha::Number::Price->new(1234567890) |
37 |
Koha::Number::Price->new(1234567890) |
34 |
->format( { with_symbol => 1 }, 'US: format 1234567890 with symbol' ), |
38 |
->format( { %$format, with_symbol => 1 }, 'US: format 1234567890 with symbol' ), |
35 |
'1,234,567,890.00' |
39 |
'1,234,567,890.00' |
36 |
); |
40 |
); |
37 |
|
41 |
|
Lines 50-69
$currency = {
Link Here
|
50 |
|
54 |
|
51 |
# Actually,the price formating for France is 3,00€ |
55 |
# Actually,the price formating for France is 3,00€ |
52 |
# How put the symbol at the end with Number::Format? |
56 |
# How put the symbol at the end with Number::Format? |
53 |
is( Koha::Number::Price->new->format, '0,00', 'FR: format 0' ); |
57 |
is( Koha::Number::Price->new->format( $format ), '0,00', 'FR: format 0' ); |
54 |
is( Koha::Number::Price->new(3)->format, '3,00', 'FR: format 3' ); |
58 |
is( Koha::Number::Price->new(3)->format( $format ), '3,00', 'FR: format 3' ); |
55 |
is( |
59 |
is( |
56 |
Koha::Number::Price->new(1234567890)->format, |
60 |
Koha::Number::Price->new(1234567890)->format( $format ), |
57 |
'1 234 567 890,00', |
61 |
'1 234 567 890,00', |
58 |
'FR: format 1234567890' |
62 |
'FR: format 1234567890' |
59 |
); |
63 |
); |
60 |
is( Koha::Number::Price->new->format( { with_symbol => 1 } ), |
64 |
is( Koha::Number::Price->new->format( { %$format, with_symbol => 1 } ), |
61 |
'€0,00', 'FR: format 0 with symbol' ); |
65 |
'€0,00', 'FR: format 0 with symbol' ); |
62 |
is( Koha::Number::Price->new(3)->format( { with_symbol => 1 } ), |
66 |
is( Koha::Number::Price->new(3)->format( { %$format, with_symbol => 1 } ), |
63 |
'€3,00', 'FR: format 3 with symbol' ); |
67 |
'€3,00', 'FR: format 3 with symbol' ); |
64 |
is( |
68 |
is( |
65 |
Koha::Number::Price->new(1234567890) |
69 |
Koha::Number::Price->new(1234567890) |
66 |
->format( { with_symbol => 1 }, 'FR: format 123567890 with symbol' ), |
70 |
->format( { %$format, with_symbol => 1 }, 'FR: format 123567890 with symbol' ), |
67 |
'€1 234 567 890,00' |
71 |
'€1 234 567 890,00' |
68 |
); |
72 |
); |
69 |
|
73 |
|
70 |
- |
|
|