mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Fixing XmlHelper::elem() when rendering non-empty content values, fixes #4300
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6520 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
82f4427b8b
commit
c096e20350
2 changed files with 8 additions and 3 deletions
|
@ -126,15 +126,15 @@ class XmlHelper extends AppHelper {
|
|||
* @return string XML
|
||||
*/
|
||||
function elem($name, $attrib = array(), $content = null, $endTag = true) {
|
||||
|
||||
$ns = null;
|
||||
|
||||
if (isset($attrib['namespace'])) {
|
||||
$ns = $attrib['namespace'] . ':';
|
||||
unset($attrib['namespace']);
|
||||
}
|
||||
$out = "<{$ns}{$name}" . $this->__composeAttributes($attrib);
|
||||
|
||||
if (empty($content) && $endTag) {
|
||||
if ((empty($content) && $content !== 0) && $endTag) {
|
||||
$out .= ' />';
|
||||
} else {
|
||||
$out .= '>' . $this->__composeContent($content);
|
||||
|
@ -142,7 +142,6 @@ class XmlHelper extends AppHelper {
|
|||
$out .= "</{$name}>";
|
||||
}
|
||||
}
|
||||
|
||||
return $this->output($out);
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -65,6 +65,12 @@ class XmlHelperTest extends UnitTestCase {
|
|||
$this->assertEqual($manager->namespaces, $expected);
|
||||
}
|
||||
|
||||
function testRenderZeroElement() {
|
||||
$result = $this->Xml->elem('count', null, 0);
|
||||
$expected = '<count>0</count>';
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
unset($this->Xml);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue