mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-14 19:08:25 +00:00
test: Restore if LC_NUMERIC is changed during testing.
Improved PostgresTest::testLocalizedFloats(). This test changes the locale (LC_NUMERIC) and restores it last. Therefore, if the test failed, subsequent tests referencing the locale could fail.
This commit is contained in:
parent
0ec6365f9d
commit
ca2c909ac9
1 changed files with 13 additions and 3 deletions
|
@ -209,6 +209,13 @@ class PostgresTest extends CakeTestCase {
|
|||
*/
|
||||
public $Dbo2 = null;
|
||||
|
||||
/**
|
||||
* Number locale before changing during testing
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $restoreLocaleNumeric = null;
|
||||
|
||||
/**
|
||||
* Sets up a Dbo class instance for testing
|
||||
*
|
||||
|
@ -232,6 +239,11 @@ class PostgresTest extends CakeTestCase {
|
|||
parent::tearDown();
|
||||
Configure::write('Cache.disable', false);
|
||||
unset($this->Dbo2);
|
||||
|
||||
if (!is_null($this->restoreLocaleNumeric)) {
|
||||
setlocale(LC_NUMERIC, $this->restoreLocaleNumeric);
|
||||
$this->restoreLocaleNumeric = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -349,7 +361,7 @@ class PostgresTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testLocalizedFloats() {
|
||||
$restore = setlocale(LC_NUMERIC, 0);
|
||||
$this->restoreLocaleNumeric = setlocale(LC_NUMERIC, 0);
|
||||
|
||||
$this->skipIf(setlocale(LC_NUMERIC, 'de_DE') === false, "The German locale isn't available.");
|
||||
|
||||
|
@ -358,8 +370,6 @@ class PostgresTest extends CakeTestCase {
|
|||
|
||||
$result = $this->db->value(3.14);
|
||||
$this->assertEquals("3.140000", $result);
|
||||
|
||||
setlocale(LC_NUMERIC, $restore);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue