mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
test: restore changed locale in tearDown()
This commit is contained in:
parent
a51b07c4c1
commit
1aeb5b3ab4
@ -19,14 +19,25 @@ use Locale;
|
|||||||
*/
|
*/
|
||||||
final class TimeDifferenceTest extends CIUnitTestCase
|
final class TimeDifferenceTest extends CIUnitTestCase
|
||||||
{
|
{
|
||||||
|
private string $currentLocale;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
helper('date');
|
helper('date');
|
||||||
|
|
||||||
|
$this->currentLocale = Locale::getDefault();
|
||||||
Locale::setDefault('America/Chicago');
|
Locale::setDefault('America/Chicago');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function tearDown(): void
|
||||||
|
{
|
||||||
|
parent::tearDown();
|
||||||
|
|
||||||
|
Locale::setDefault($this->currentLocale);
|
||||||
|
}
|
||||||
|
|
||||||
public function testDifferenceBasics()
|
public function testDifferenceBasics()
|
||||||
{
|
{
|
||||||
$current = Time::parse('March 10, 2017', 'America/Chicago');
|
$current = Time::parse('March 10, 2017', 'America/Chicago');
|
||||||
|
@ -25,14 +25,25 @@ use Locale;
|
|||||||
*/
|
*/
|
||||||
final class TimeTest extends CIUnitTestCase
|
final class TimeTest extends CIUnitTestCase
|
||||||
{
|
{
|
||||||
|
private string $currentLocale;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
helper('date');
|
helper('date');
|
||||||
|
|
||||||
|
$this->currentLocale = Locale::getDefault();
|
||||||
Locale::setDefault('en_US');
|
Locale::setDefault('en_US');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function tearDown(): void
|
||||||
|
{
|
||||||
|
parent::tearDown();
|
||||||
|
|
||||||
|
Locale::setDefault($this->currentLocale);
|
||||||
|
}
|
||||||
|
|
||||||
public function testNewTimeNow()
|
public function testNewTimeNow()
|
||||||
{
|
{
|
||||||
$formatter = new IntlDateFormatter(
|
$formatter = new IntlDateFormatter(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user