Lines 1-6
Link Here
|
1 |
use Modern::Perl; |
1 |
use Modern::Perl; |
2 |
|
2 |
|
3 |
use Test::More tests => 31; |
3 |
use Test::More tests => 32; |
4 |
|
4 |
|
5 |
use Test::MockModule; |
5 |
use Test::MockModule; |
6 |
use t::lib::Mocks; |
6 |
use t::lib::Mocks; |
Lines 18-24
use_ok('Koha::Number::Price');
Link Here
|
18 |
my $orig_locale = setlocale(LC_NUMERIC); |
18 |
my $orig_locale = setlocale(LC_NUMERIC); |
19 |
my $format = { |
19 |
my $format = { |
20 |
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 |
21 |
p_sep_by_space => 0, # Force to not add a space between the symbol and the number |
|
|
22 |
}; |
21 |
}; |
23 |
t::lib::Mocks::mock_preference( 'CurrencyFormat', 'US' ); |
22 |
t::lib::Mocks::mock_preference( 'CurrencyFormat', 'US' ); |
24 |
$currency = Koha::Acquisition::Currency->new({ |
23 |
$currency = Koha::Acquisition::Currency->new({ |
Lines 26-31
$currency = Koha::Acquisition::Currency->new({
Link Here
|
26 |
symbol => '$', |
25 |
symbol => '$', |
27 |
rate => 1, |
26 |
rate => 1, |
28 |
active => 1, |
27 |
active => 1, |
|
|
28 |
p_sep_by_space => 0, # Force to not add a space between the symbol and the number. This is the default behaviour |
29 |
}); |
29 |
}); |
30 |
|
30 |
|
31 |
is( Koha::Number::Price->new->format( $format ), '0.00', 'US: format 0' ); |
31 |
is( Koha::Number::Price->new->format( $format ), '0.00', 'US: format 0' ); |
Lines 45-50
is(
Link Here
|
45 |
'$1,234,567,890.00' |
45 |
'$1,234,567,890.00' |
46 |
); |
46 |
); |
47 |
|
47 |
|
|
|
48 |
$currency->p_sep_by_space(1); |
49 |
is( Koha::Number::Price->new(3)->format( { %$format, with_symbol => 1 } ), |
50 |
'$ 3.00', 'US: format 3 with symbol and a space' ); |
51 |
|
48 |
is( Koha::Number::Price->new->unformat, '0', 'US: unformat 0' ); |
52 |
is( Koha::Number::Price->new->unformat, '0', 'US: unformat 0' ); |
49 |
is( Koha::Number::Price->new(3)->unformat, '3', 'US: unformat 3' ); |
53 |
is( Koha::Number::Price->new(3)->unformat, '3', 'US: unformat 3' ); |
50 |
is( Koha::Number::Price->new(1234567890)->unformat, |
54 |
is( Koha::Number::Price->new(1234567890)->unformat, |
51 |
- |
|
|