Bug 4078: Add a new test
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 1 Feb 2018 17:35:06 +0000 (14:35 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 23 Mar 2018 14:45:38 +0000 (11:45 -0300)
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
t/Number/Price.t

index 4b706b3..1676c8a 100644 (file)
@@ -1,6 +1,6 @@
 use Modern::Perl;
 
-use Test::More tests => 31;
+use Test::More tests => 32;
 
 use Test::MockModule;
 use t::lib::Mocks;
@@ -18,7 +18,6 @@ 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
 };
 t::lib::Mocks::mock_preference( 'CurrencyFormat', 'US' );
 $currency = Koha::Acquisition::Currency->new({
@@ -26,6 +25,7 @@ $currency = Koha::Acquisition::Currency->new({
     symbol   => '$',
     rate     => 1,
     active   => 1,
+    p_sep_by_space => 0, # Force to not add a space between the symbol and the number. This is the default behaviour
 });
 
 is( Koha::Number::Price->new->format( $format ),    '0.00', 'US: format 0' );
@@ -45,6 +45,10 @@ is(
     '$1,234,567,890.00'
 );
 
+$currency->p_sep_by_space(1);
+is( Koha::Number::Price->new(3)->format( { %$format, with_symbol => 1 } ),
+    '$ 3.00', 'US: format 3 with symbol and a space' );
+
 is( Koha::Number::Price->new->unformat,    '0', 'US: unformat 0' );
 is( Koha::Number::Price->new(3)->unformat, '3', 'US: unformat 3' );
 is( Koha::Number::Price->new(1234567890)->unformat,