diff --git a/src/Database/Type/DecimalType.php b/src/Database/Type/DecimalType.php index e9812254fe3..a15e90a4cc8 100644 --- a/src/Database/Type/DecimalType.php +++ b/src/Database/Type/DecimalType.php @@ -129,12 +129,12 @@ public function marshal($value) if ($value === null || $value === '') { return null; } - if (is_numeric($value)) { - return (float)$value; - } if (is_string($value) && $this->_useLocaleParser) { return $this->_parseValue($value); } + if (is_numeric($value)) { + return (float)$value; + } if (is_array($value)) { return 1; } diff --git a/tests/TestCase/Database/Type/DecimalTypeTest.php b/tests/TestCase/Database/Type/DecimalTypeTest.php index 9b50947bb3b..2fea70375ff 100644 --- a/tests/TestCase/Database/Type/DecimalTypeTest.php +++ b/tests/TestCase/Database/Type/DecimalTypeTest.php @@ -181,6 +181,21 @@ public function testMarshalWithLocaleParsing() $this->assertEquals($expected, $result); } + /** + * test marshall() number in the danish locale which uses . for thousands separator. + * + * @return void + */ + public function testMarshallWithLocaleParsingDanish() + { + I18n::setLocale('da_DK'); + + $this->type->useLocaleParser(); + $expected = 47500.0; + $result = $this->type->marshal('47.500'); + $this->assertSame($expected, $result); + } + /** * Test that exceptions are raised on invalid parsers. *