Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Commit

Permalink
Fix tests with no locales + Apply CSFixer fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
adrilo committed Nov 12, 2021
1 parent 65b5ad7 commit be195dc
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ jobs:
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Run PHP-CS-Fixer
run: vendor/bin/php-cs-fixer fix --config=.php_cs.dist --verbose --diff --dry-run --diff-format=udiff
run: vendor/bin/php-cs-fixer fix --verbose --diff --dry-run --diff-format=udiff

static-analysis:
name: Static Analysis
Expand Down
4 changes: 2 additions & 2 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'no_break_comment' => ['comment_text' => 'do nothing'],
'no_empty_phpdoc' => false,
'no_null_property_initialization' => true,
'no_short_echo_tag' => true,
'echo_tag_syntax' => false,
'no_superfluous_elseif' => true,
'no_superfluous_phpdoc_tags' => false,
'no_unneeded_control_parentheses' => ['statements' => ['break', 'clone', 'continue', 'echo_print', 'switch_case', 'yield']],
Expand All @@ -37,7 +37,7 @@
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
'phpdoc_separation' => false,
'protected_to_private' => true,
'psr4' => true,
'psr_autoloading' => true,
'return_type_declaration' => ['space_before' => 'one'],
'semicolon_after_instruction' => true,
'simplified_null_return' => false,
Expand Down
11 changes: 9 additions & 2 deletions tests/Spout/Writer/ODS/WriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,19 @@ public function testAddRowShouldSupportFloatValuesInDifferentLocale()
// Installed locales differ from one system to another, so we can't pick
// a given locale.
$supportedLocales = explode("\n", shell_exec('locale -a'));
$foundCommaLocale = false;
foreach ($supportedLocales as $supportedLocale) {
\setlocale(LC_ALL, $supportedLocale);
if (\localeconv()['decimal_point'] === ',') {
$foundCommaLocale = true;
break;
}
}

if (!$foundCommaLocale) {
$this->markTestSkipped('No locale with comma decimal separator');
}

$this->assertEquals(',', \localeconv()['decimal_point']);

$fileName = 'test_add_row_should_support_float_values_in_different_locale.xlsx';
Expand All @@ -306,8 +313,8 @@ public function testAddRowShouldSupportFloatValuesInDifferentLocale()

$this->writeToODSFile($dataRows, $fileName);

$this->assertValueWasNotWrittenToSheet($fileName, 1, "1234,5");
$this->assertValueWasWrittenToSheet($fileName, 1, "1234.5");
$this->assertValueWasNotWrittenToSheet($fileName, 1, '1234,5');
$this->assertValueWasWrittenToSheet($fileName, 1, '1234.5');
} finally {
// reset locale
\setlocale(LC_ALL, $previousLocale);
Expand Down
11 changes: 9 additions & 2 deletions tests/Spout/Writer/XLSX/WriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,12 +406,19 @@ public function testAddRowShouldSupportFloatValuesInDifferentLocale()
// Installed locales differ from one system to another, so we can't pick
// a given locale.
$supportedLocales = explode("\n", shell_exec('locale -a'));
$foundCommaLocale = false;
foreach ($supportedLocales as $supportedLocale) {
\setlocale(LC_ALL, $supportedLocale);
if (\localeconv()['decimal_point'] === ',') {
$foundCommaLocale = true;
break;
}
}

if (!$foundCommaLocale) {
$this->markTestSkipped('No locale with comma decimal separator');
}

$this->assertEquals(',', \localeconv()['decimal_point']);

$fileName = 'test_add_row_should_support_float_values_in_different_locale.xlsx';
Expand All @@ -421,8 +428,8 @@ public function testAddRowShouldSupportFloatValuesInDifferentLocale()

$this->writeToXLSXFile($dataRows, $fileName, $shouldUseInlineStrings = false);

$this->assertInlineDataWasNotWrittenToSheet($fileName, 1, "1234,5");
$this->assertInlineDataWasWrittenToSheet($fileName, 1, "1234.5");
$this->assertInlineDataWasNotWrittenToSheet($fileName, 1, '1234,5');
$this->assertInlineDataWasWrittenToSheet($fileName, 1, '1234.5');
} finally {
// reset locale
\setlocale(LC_ALL, $previousLocale);
Expand Down

0 comments on commit be195dc

Please sign in to comment.