Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Avoid using LC_ALL, on some installs this would cause error:

    "setlocale(): Specified locale name is too long"
  • Loading branch information...
commit cd209ce0996605bb8296d82648c3fe6132b38f39 1 parent 8b94d9e
@ceeram ceeram authored
View
8 lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php
@@ -347,8 +347,8 @@ public function testValueQuoting() {
* @return void
*/
public function testLocalizedFloats() {
- $restore = setlocale(LC_ALL, 0);
- setlocale(LC_ALL, 'de_DE');
+ $restore = setlocale(LC_NUMERIC, 0);
+ setlocale(LC_NUMERIC, 'de_DE');
$result = $this->db->value(3.141593, 'float');
$this->assertEquals("3.141593", $result);
@@ -356,7 +356,7 @@ public function testLocalizedFloats() {
$result = $this->db->value(3.14);
$this->assertEquals("3.140000", $result);
- setlocale(LC_ALL, $restore);
+ setlocale(LC_NUMERIC, $restore);
}
/**
@@ -784,7 +784,7 @@ public function testOrderAdditionalParams() {
}
/**
- * Test it is possible to do a SELECT COUNT(DISTINCT Model.field)
+ * Test it is possible to do a SELECT COUNT(DISTINCT Model.field)
* query in postgres and it gets correctly quoted
*
* @return void
View
6 lib/Cake/Test/Case/Model/ModelWriteTest.php
@@ -6313,8 +6313,8 @@ public function testUpdateAllWithoutForeignKey() {
* @return void
*/
public function testWriteFloatAsGerman() {
- $restore = setlocale(LC_ALL, 0);
- setlocale(LC_ALL, 'de_DE');
+ $restore = setlocale(LC_NUMERIC, 0);
+ setlocale(LC_NUMERIC, 'de_DE');
$model = new DataTest();
$result = $model->save(array(
@@ -6322,7 +6322,7 @@ public function testWriteFloatAsGerman() {
'float' => 3.14593
));
$this->assertTrue((bool)$result);
- setlocale(LC_ALL, $restore);
+ setlocale(LC_NUMERIC, $restore);
}
/**
View
6 lib/Cake/Test/Case/Utility/CakeNumberTest.php
@@ -490,14 +490,14 @@ public function testToReadableSize() {
* @return void
*/
public function testReadableSizeLocalized() {
- $restore = setlocale(LC_ALL, 0);
- setlocale(LC_ALL, 'de_DE');
+ $restore = setlocale(LC_NUMERIC, 0);
+ setlocale(LC_NUMERIC, 'de_DE');
$result = $this->Number->toReadableSize(1321205);
$this->assertRegExp('/1[,.]26 MB/', $result);
$result = $this->Number->toReadableSize(1024 * 1024 * 1024 * 512);
$this->assertRegExp('/512[,.]00 GB/', $result);
- setlocale(LC_ALL, $restore);
+ setlocale(LC_NUMERIC, $restore);
}
/**
View
11 lib/Cake/Test/Case/Utility/ValidationTest.php
@@ -103,8 +103,11 @@ class ValidationTest extends CakeTestCase {
public function setUp() {
parent::setUp();
$this->_appEncoding = Configure::read('App.encoding');
- $this->_appLocale = setlocale(LC_ALL, "0");
- setlocale(LC_ALL, 'en_US');
+ $this->_appLocale = array();
+ foreach (array(LC_MONETARY, LC_NUMERIC, LC_TIME) as $category) {
+ $this->_appLocale[$category] = setlocale($category, 0);
+ setlocale($category, 'en_US');
+ }
}
/**
@@ -115,7 +118,9 @@ public function setUp() {
public function tearDown() {
parent::tearDown();
Configure::write('App.encoding', $this->_appEncoding);
- setlocale(LC_ALL, $this->_appLocale);
+ foreach ($this->_appLocale as $category => $locale) {
+ setlocale($category, $locale);
+ }
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.