From a919093891cc333242ea362c871156b6054b6f11 Mon Sep 17 00:00:00 2001 From: hungtd Date: Wed, 16 Nov 2022 14:53:48 +0700 Subject: [PATCH] PHPUnit fix bug: 'Undefined array key 1' with test case base on use setlocale(LC_ALL, 0) return unexpected string format. Expected string format like that: setlocale(LC_ALL, 0) === 'LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;...' Actual string format on apline container: setlocale(LC_ALL, 0) === 'C.UTF-8;C;C;C;C;C' missing part '=Something' --- tests/Zend/LocaleTest.php | 2 +- tests/Zend/Validate/FloatTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Zend/LocaleTest.php b/tests/Zend/LocaleTest.php index 8cdee6e58d..0a98634d6f 100644 --- a/tests/Zend/LocaleTest.php +++ b/tests/Zend/LocaleTest.php @@ -94,7 +94,7 @@ protected function tearDown(): void $locales = []; foreach (explode(';', $this->_locale) as $l) { $tmp = explode('=', $l); - $locales[$tmp[0]] = $tmp[1]; + $locales[$tmp[0]] = count($tmp) > 1 ? $tmp[1] : $tmp[0]; } setlocale(LC_ALL, $locales); return; diff --git a/tests/Zend/Validate/FloatTest.php b/tests/Zend/Validate/FloatTest.php index 015ef58e0b..aa1303a1cf 100644 --- a/tests/Zend/Validate/FloatTest.php +++ b/tests/Zend/Validate/FloatTest.php @@ -74,7 +74,7 @@ protected function tearDown(): void $locales = []; foreach (explode(';', $this->_locale) as $l) { $tmp = explode('=', $l); - $locales[$tmp[0]] = $tmp[1]; + $locales[$tmp[0]] = count($tmp) > 1 ? $tmp[1] : $tmp[0]; } setlocale(LC_ALL, $locales); return;