Permalink
Browse files

Fixing XmlHelper::elem() when value is null and cdata = true. Removin…

…g empty invalid tag.

Test cases added.
Fixes #127
  • Loading branch information...
1 parent e030400 commit 06cf97459a5fbe82f66d191bf4ce192866bab548 @markstory markstory committed Sep 25, 2009
Showing with 5 additions and 1 deletion.
  1. +1 −1 cake/libs/view/helpers/xml.php
  2. +4 −0 cake/tests/cases/libs/view/helpers/xml.test.php
@@ -112,7 +112,7 @@ function elem($name, $attrib = array(), $content = null, $endTag = true) {
$cdata = true;
unset($content['cdata']);
}
- if (is_array($content) && isset($content['value'])) {
+ if (is_array($content) && array_key_exists('value', $content)) {
$content = $content['value'];
}
$children = array();
@@ -131,6 +131,10 @@ function testRenderZeroElement() {
$result = $this->Xml->elem('count', null, 0);
$expected = '<count>0</count>';
$this->assertEqual($result, $expected);
+
+ $result = $this->Xml->elem('count', null, array('cdata' => true, 'value' => null));
+ $expected = '<count />';
+ $this->assertEqual($result, $expected);
}
/**
* testRenderElementWithNamespace method

0 comments on commit 06cf974

Please sign in to comment.