Skip to content
This repository
Browse code

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

…g empty invalid tag.

Test cases added.
Fixes #127
  • Loading branch information...
commit 06cf97459a5fbe82f66d191bf4ce192866bab548 1 parent e030400
Mark Story authored September 24, 2009
2  cake/libs/view/helpers/xml.php
@@ -112,7 +112,7 @@ function elem($name, $attrib = array(), $content = null, $endTag = true) {
112 112
 			$cdata = true;
113 113
 			unset($content['cdata']);
114 114
 		}
115  
-		if (is_array($content) && isset($content['value'])) {
  115
+		if (is_array($content) && array_key_exists('value', $content)) {
116 116
 			$content = $content['value'];
117 117
 		}
118 118
 		$children = array();
4  cake/tests/cases/libs/view/helpers/xml.test.php
@@ -131,6 +131,10 @@ function testRenderZeroElement() {
131 131
 		$result = $this->Xml->elem('count', null, 0);
132 132
 		$expected = '<count>0</count>';
133 133
 		$this->assertEqual($result, $expected);
  134
+
  135
+		$result = $this->Xml->elem('count', null, array('cdata' => true, 'value' => null));
  136
+		$expected = '<count />';
  137
+		$this->assertEqual($result, $expected);
134 138
 	}
135 139
 /**
136 140
  * testRenderElementWithNamespace method

0 notes on commit 06cf974

Please sign in to comment.
Something went wrong with that request. Please try again.