From d98118ac05ad1665d723602dfb579fdcae9e74c7 Mon Sep 17 00:00:00 2001 From: Luis Cordova Date: Fri, 12 Apr 2013 09:43:46 -0500 Subject: [PATCH] [Config] #7644 add tests for passing number looking attributes as strings --- .../Component/Config/Tests/Util/XmlUtilsTest.php | 10 +++++++++- src/Symfony/Component/Config/Util/XmlUtils.php | 4 ++-- .../Tests/Fixtures/xml/services2.xml | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php index a3d264e1891c..feb796b68f37 100644 --- a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php +++ b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php @@ -117,7 +117,15 @@ public function getDataForPhpize() array(100.0, '1e2'), array(-120.0, '-1.2E2'), array(-10100.1, '-10100.1'), - array(-10100.1, '-10,100.1'), + array('-10,100.1', '-10,100.1'), + array('1234 5678 9101 1121 3141', '1234 5678 9101 1121 3141'), + array('1,2,3,4', '1,2,3,4'), + array('11,22,33,44', '11,22,33,44'), + array('11,222,333,4', '11,222,333,4'), + array('1,222,333,444', '1,222,333,444'), + array('11,222,333,444', '11,222,333,444'), + array('111,222,333,444', '111,222,333,444'), + array('1111,2222,3333,4444,5555', '1111,2222,3333,4444,5555'), array('foo', 'foo'), ); } diff --git a/src/Symfony/Component/Config/Util/XmlUtils.php b/src/Symfony/Component/Config/Util/XmlUtils.php index 9317e15e7c77..2e9d86ec2167 100644 --- a/src/Symfony/Component/Config/Util/XmlUtils.php +++ b/src/Symfony/Component/Config/Util/XmlUtils.php @@ -193,8 +193,8 @@ public static function phpize($value) return false; case is_numeric($value): return '0x' == $value[0].$value[1] ? hexdec($value) : floatval($value); - case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $value): - return floatval(str_replace(',', '', $value)); + case preg_match('/^(-|\+)?[0-9]+(\.[0-9]+)?$/', $value): + return floatval($value); default: return $value; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services2.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services2.xml index bada1c892fb0..6e8a6ce364dc 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services2.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services2.xml @@ -16,7 +16,7 @@ on off 1.3 - 1,000.3 + 1000.3 a string foo