3 use Test::More tests => 19;
9 my $budget_module = Test::MockModule->new('C4::Budgets');
11 $budget_module->mock( 'GetCurrency', sub { return $currency; } );
12 use_ok('Koha::Number::Price');
14 t::lib::Mocks::mock_preference( 'CurrencyFormat', 'US' );
22 is( Koha::Number::Price->new->format, '0.00', 'US: format 0' );
23 is( Koha::Number::Price->new(3)->format, '3.00', 'US: format 3' );
24 is( Koha::Number::Price->new(1234567890)->format,
25 '1,234,567,890.00', 'US: format 1234567890' );
27 # 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 } ),
29 '0.00', 'US: format 0 with symbol' );
30 is( Koha::Number::Price->new(3)->format( { with_symbol => 1 } ),
31 '3.00', 'US: format 3 with symbol' );
33 Koha::Number::Price->new(1234567890)
34 ->format( { with_symbol => 1 }, 'US: format 1234567890 with symbol' ),
38 is( Koha::Number::Price->new->unformat, '0', 'US: unformat 0' );
39 is( Koha::Number::Price->new(3)->unformat, '3', 'US: unformat 3' );
40 is( Koha::Number::Price->new(1234567890)->unformat,
41 '1234567890', 'US: unformat 1234567890' );
43 t::lib::Mocks::mock_preference( 'CurrencyFormat', 'FR' );
51 # Actually,the price formating for France is 3,00€
52 # How put the symbol at the end with Number::Format?
53 is( Koha::Number::Price->new->format, '0,00', 'FR: format 0' );
54 is( Koha::Number::Price->new(3)->format, '3,00', 'FR: format 3' );
56 Koha::Number::Price->new(1234567890)->format,
58 'FR: format 1234567890'
60 is( Koha::Number::Price->new->format( { with_symbol => 1 } ),
61 '€0,00', 'FR: format 0 with symbol' );
62 is( Koha::Number::Price->new(3)->format( { with_symbol => 1 } ),
63 '€3,00', 'FR: format 3 with symbol' );
65 Koha::Number::Price->new(1234567890)
66 ->format( { with_symbol => 1 }, 'FR: format 123567890 with symbol' ),
70 is( Koha::Number::Price->new->unformat, '0', 'FR: unformat 0' );
71 is( Koha::Number::Price->new(3)->unformat, '3', 'FR: unformat 3' );
72 is( Koha::Number::Price->new(1234567890)->unformat,
73 '1234567890', 'FR: unformat 1234567890' );