Skip to content

Commit cd209ce

Browse files
committed
Avoid using LC_ALL, on some installs this would cause error:
"setlocale(): Specified locale name is too long"
1 parent 8b94d9e commit cd209ce

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,16 +347,16 @@ public function testValueQuoting() {
347347
* @return void
348348
*/
349349
public function testLocalizedFloats() {
350-
$restore = setlocale(LC_ALL, 0);
351-
setlocale(LC_ALL, 'de_DE');
350+
$restore = setlocale(LC_NUMERIC, 0);
351+
setlocale(LC_NUMERIC, 'de_DE');
352352

353353
$result = $this->db->value(3.141593, 'float');
354354
$this->assertEquals("3.141593", $result);
355355

356356
$result = $this->db->value(3.14);
357357
$this->assertEquals("3.140000", $result);
358358

359-
setlocale(LC_ALL, $restore);
359+
setlocale(LC_NUMERIC, $restore);
360360
}
361361

362362
/**
@@ -784,7 +784,7 @@ public function testOrderAdditionalParams() {
784784
}
785785

786786
/**
787-
* Test it is possible to do a SELECT COUNT(DISTINCT Model.field)
787+
* Test it is possible to do a SELECT COUNT(DISTINCT Model.field)
788788
* query in postgres and it gets correctly quoted
789789
*
790790
* @return void

lib/Cake/Test/Case/Model/ModelWriteTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6313,16 +6313,16 @@ public function testUpdateAllWithoutForeignKey() {
63136313
* @return void
63146314
*/
63156315
public function testWriteFloatAsGerman() {
6316-
$restore = setlocale(LC_ALL, 0);
6317-
setlocale(LC_ALL, 'de_DE');
6316+
$restore = setlocale(LC_NUMERIC, 0);
6317+
setlocale(LC_NUMERIC, 'de_DE');
63186318

63196319
$model = new DataTest();
63206320
$result = $model->save(array(
63216321
'count' => 1,
63226322
'float' => 3.14593
63236323
));
63246324
$this->assertTrue((bool)$result);
6325-
setlocale(LC_ALL, $restore);
6325+
setlocale(LC_NUMERIC, $restore);
63266326
}
63276327

63286328
/**

lib/Cake/Test/Case/Utility/CakeNumberTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,14 +490,14 @@ public function testToReadableSize() {
490490
* @return void
491491
*/
492492
public function testReadableSizeLocalized() {
493-
$restore = setlocale(LC_ALL, 0);
494-
setlocale(LC_ALL, 'de_DE');
493+
$restore = setlocale(LC_NUMERIC, 0);
494+
setlocale(LC_NUMERIC, 'de_DE');
495495
$result = $this->Number->toReadableSize(1321205);
496496
$this->assertRegExp('/1[,.]26 MB/', $result);
497497

498498
$result = $this->Number->toReadableSize(1024 * 1024 * 1024 * 512);
499499
$this->assertRegExp('/512[,.]00 GB/', $result);
500-
setlocale(LC_ALL, $restore);
500+
setlocale(LC_NUMERIC, $restore);
501501
}
502502

503503
/**

lib/Cake/Test/Case/Utility/ValidationTest.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,11 @@ class ValidationTest extends CakeTestCase {
103103
public function setUp() {
104104
parent::setUp();
105105
$this->_appEncoding = Configure::read('App.encoding');
106-
$this->_appLocale = setlocale(LC_ALL, "0");
107-
setlocale(LC_ALL, 'en_US');
106+
$this->_appLocale = array();
107+
foreach (array(LC_MONETARY, LC_NUMERIC, LC_TIME) as $category) {
108+
$this->_appLocale[$category] = setlocale($category, 0);
109+
setlocale($category, 'en_US');
110+
}
108111
}
109112

110113
/**
@@ -115,7 +118,9 @@ public function setUp() {
115118
public function tearDown() {
116119
parent::tearDown();
117120
Configure::write('App.encoding', $this->_appEncoding);
118-
setlocale(LC_ALL, $this->_appLocale);
121+
foreach ($this->_appLocale as $category => $locale) {
122+
setlocale($category, $locale);
123+
}
119124
}
120125

121126
/**

0 commit comments

Comments
 (0)