Skip to content

Commit

Permalink
Adding test cases for using localized floats with mysql. Also added a…
Browse files Browse the repository at this point in the history
… generic model test case. Refs #1029
  • Loading branch information
markstory committed Aug 21, 2010
1 parent e23fe25 commit afc05c1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php
Expand Up @@ -277,6 +277,24 @@ function testQuoting() {
$this->assertEqual($expected, $result);
}

/**
* test that localized floats don't cause trouble.
*
* @return void
*/
function testLocalizedFloats() {
$restore = setlocale(LC_ALL, null);
setlocale(LC_ALL, 'de_DE');

$result = $this->db->value(3.141593, 'float');
$this->assertEqual((string)$result, '3.141593');

$result = $this->db->value(3.141593);
$this->assertEqual((string)$result, '3.141593');

setlocale(LC_ALL, $restore);
}

/**
* testTinyintCasting method
*
Expand Down
18 changes: 18 additions & 0 deletions cake/tests/cases/libs/model/model_write.test.php
Expand Up @@ -3880,4 +3880,22 @@ function testSaveAllEmptyData() {
$this->assertFalse($result);
}

/**
* test writing floats in german locale.
*
* @return void
*/
function testWriteFloatAsGerman() {
$restore = setlocale(LC_ALL, null);
setlocale(LC_ALL, 'de_DE');

$model = new DataTest();
$result = $model->save(array(
'count' => 1,
'float' => 3.14593
));
$this->assertTrue($result);
setlocale(LC_ALL, $restore);
}

}

0 comments on commit afc05c1

Please sign in to comment.