Adding slug option to avoid auto-slug of tags. Test included. Addresses #284

Signed-off-by: mark_story <mark@mark-story.com>
This commit is contained in:
teknoid 2010-07-13 14:43:10 -04:00 committed by mark_story
parent 5c27abd35f
commit 503b7cf5d7
2 changed files with 19 additions and 1 deletions

View file

@ -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));
}

View file

@ -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 = '<USERS><USER><ID>1</ID></USER><USER><ID>2</ID></USER></USERS>';
$this->assertIdentical($result->toString(), $expected);
}
/**
* test serialization of boolean and null values. false = 0, true = 1, null = ''
*