Bug 18900: add UT to Number/Price.t
This patch adds unit tests to t/Number/Price.t in order to valid the problem. Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
04966a6203
commit
91dee226cd
|
|
@ -1,16 +1,21 @@
|
|||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 28;
|
||||
use Test::More tests => 30;
|
||||
|
||||
use Test::MockModule;
|
||||
use t::lib::Mocks;
|
||||
|
||||
# Number formating depends by default on system environement
|
||||
# See http://search.cpan.org/~wrw/Number-Format/Format.pm
|
||||
use POSIX qw(setlocale LC_NUMERIC);
|
||||
|
||||
use Koha::Acquisition::Currencies;
|
||||
my $budget_module = Test::MockModule->new('Koha::Acquisition::Currencies');
|
||||
my $currency;
|
||||
$budget_module->mock( 'get_active', sub { return $currency; } );
|
||||
use_ok('Koha::Number::Price');
|
||||
|
||||
my $orig_locale = setlocale(LC_NUMERIC);
|
||||
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
|
||||
|
|
@ -44,6 +49,14 @@ is( Koha::Number::Price->new(3)->unformat, '3', 'US: unformat 3' );
|
|||
is( Koha::Number::Price->new(1234567890)->unformat,
|
||||
'1234567890', 'US: unformat 1234567890' );
|
||||
|
||||
# Bug 18900 - Check params are not from system environement
|
||||
setlocale(LC_NUMERIC, "fr_FR.UTF-8");
|
||||
is( Koha::Number::Price->new(12345678.9)->format( { %$format, with_symbol => 1 } ),
|
||||
'12,345,678.90', 'US: format 12,345,678.90 with symbol' );
|
||||
is( Koha::Number::Price->new('12,345,678.90')->unformat,
|
||||
'12345678.9', 'US: unformat 12345678.9' );
|
||||
setlocale(LC_NUMERIC, $orig_locale);
|
||||
|
||||
t::lib::Mocks::mock_preference( 'CurrencyFormat', 'FR' );
|
||||
$currency = Koha::Acquisition::Currency->new({
|
||||
currency => 'EUR',
|
||||
|
|
|
|||
Loading…
Reference in New Issue