Skip to content

Commit 57385ea

Browse files
authored
Merge pull request #6460 from kenjis/fix-test-restore-locales
test: restore changed locale in Time tests
2 parents 5b396db + 528eed7 commit 57385ea

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

tests/system/I18n/TimeDifferenceTest.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,23 @@
1919
*/
2020
final class TimeDifferenceTest extends CIUnitTestCase
2121
{
22+
private string $currentLocale;
23+
2224
protected function setUp(): void
2325
{
2426
parent::setUp();
2527

2628
helper('date');
27-
Locale::setDefault('America/Chicago');
29+
30+
$this->currentLocale = Locale::getDefault();
31+
Locale::setDefault('en-US');
32+
}
33+
34+
protected function tearDown(): void
35+
{
36+
parent::tearDown();
37+
38+
Locale::setDefault($this->currentLocale);
2839
}
2940

3041
public function testDifferenceBasics()

tests/system/I18n/TimeTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,25 @@
2525
*/
2626
final class TimeTest extends CIUnitTestCase
2727
{
28+
private string $currentLocale;
29+
2830
protected function setUp(): void
2931
{
3032
parent::setUp();
3133

3234
helper('date');
35+
36+
$this->currentLocale = Locale::getDefault();
3337
Locale::setDefault('en_US');
3438
}
3539

40+
protected function tearDown(): void
41+
{
42+
parent::tearDown();
43+
44+
Locale::setDefault($this->currentLocale);
45+
}
46+
3647
public function testNewTimeNow()
3748
{
3849
$formatter = new IntlDateFormatter(

0 commit comments

Comments
 (0)