From 9efbcf00a2b9a275e6242224e9c3e3430ae2d6a7 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 9 Aug 2017 12:01:17 -0300 Subject: [PATCH] Bug 18900: (QA followup) Make tests conditional to locale existence It is important to highlight that tests have been skipped instead of having them pass on the absence of the required fr_FR.UTF-8 locale installed on the system. This patch does that check and effectively skips them. Signed-off-by: Tomas Cohen Arazi --- t/Number/Price.t | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/t/Number/Price.t b/t/Number/Price.t index 99d23bc..68365c3 100644 --- a/t/Number/Price.t +++ b/t/Number/Price.t @@ -49,13 +49,20 @@ 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); +SKIP: { + # Bug 18900 - Check params are not from system environement + setlocale(LC_NUMERIC, "fr_FR.UTF-8"); + my $current_locale = setlocale(LC_NUMERIC); + + skip "fr_FR.UTF-8 locale required for tests and missing", 2 + unless $current_locale eq '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({ -- 2.7.4