From 503b7cf5d73b0b82778a97d3d75207b92480d102 Mon Sep 17 00:00:00 2001 From: teknoid Date: Tue, 13 Jul 2010 14:43:10 -0400 Subject: [PATCH] Adding slug option to avoid auto-slug of tags. Test included. Addresses #284 Signed-off-by: mark_story --- cake/libs/xml.php | 2 +- cake/tests/cases/libs/xml.test.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/cake/libs/xml.php b/cake/libs/xml.php index 8d5842e1b..ecbe6a27b 100644 --- a/cake/libs/xml.php +++ b/cake/libs/xml.php @@ -216,7 +216,7 @@ class XmlNode extends Object { if (isset($tagOpts['name'])) { $name = $tagOpts['name']; - } elseif ($name != strtolower($name)) { + } elseif ($name != strtolower($name) && $options['slug'] !== false) { $name = Inflector::slug(Inflector::underscore($name)); } diff --git a/cake/tests/cases/libs/xml.test.php b/cake/tests/cases/libs/xml.test.php index c1b1de70c..d1b6958ff 100644 --- a/cake/tests/cases/libs/xml.test.php +++ b/cake/tests/cases/libs/xml.test.php @@ -113,6 +113,24 @@ class XmlTest extends CakeTestCase { $this->assertIdentical($result->toString(), $expected); } +/** + * testSerializeCapsWithoutSlug method + * + * @access public + * @return void + */ + function testSerializeCapsWithoutSlug() { + $data = array( + 'USERS' => array( + array('USER' => array('ID' => 1)), + array('USER' => array('ID' => 2)) + ) + ); + $result =& new Xml($data, array('format' => 'tags', 'slug' => false)); + $expected = '12'; + $this->assertIdentical($result->toString(), $expected); + } + /** * test serialization of boolean and null values. false = 0, true = 1, null = '' *