mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
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:
parent
5c27abd35f
commit
503b7cf5d7
2 changed files with 19 additions and 1 deletions
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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 = ''
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue