Bug 18900: (QA followup) Make tests conditional to locale existence
authorTomas Cohen Arazi <tomascohen@theke.io>
Wed, 9 Aug 2017 15:01:17 +0000 (12:01 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 10 Aug 2017 16:20:32 +0000 (13:20 -0300)
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 <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
t/Number/Price.t

index 99d23bc..68365c3 100644 (file)
@@ -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({