Fix tests with no locales + Apply CSFixer fixes

This commit is contained in:
Adrien Loison 2021-11-12 15:00:14 +01:00
parent f8595e9d63
commit 0345b369c7
4 changed files with 21 additions and 7 deletions

View File

@ -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

View File

@ -19,7 +19,7 @@ $config = PhpCsFixer\Config::create()
'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']],
@ -37,7 +37,7 @@ $config = PhpCsFixer\Config::create()
'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,

View File

@ -291,12 +291,19 @@ class WriterTest extends TestCase
// 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';
@ -306,8 +313,8 @@ class WriterTest extends TestCase
$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);

View File

@ -406,12 +406,19 @@ class WriterTest extends TestCase
// 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';
@ -421,8 +428,8 @@ class WriterTest extends TestCase
$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);