Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Zend\Log: ZF2-453 test for xml extra array prossing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralph Schindler committed Aug 16, 2012
1 parent c08e950 commit 17b56b8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Formatter/Xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function format($event)
) {
if ($key == "message") {
$value = htmlspecialchars($value, ENT_COMPAT, $enc);
} elseif($key == "extra" && empty($value)) {
} elseif ($key == "extra" && empty($value)) {
continue;
}
$elt->appendChild(new DOMElement($key, (string)$value));
Expand Down
19 changes: 19 additions & 0 deletions test/Formatter/XmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,23 @@ public function testObjectsWithStringSerializationAreIncludedInFormattedString()
$output = $formatter->format($event);
$this->assertContains($expected, $output);
}

/**
* @group ZF2-453
*/
public function testFormatWillRemoveExtraEmptyArrayFromEvent()
{
$formatter = new XmlFormatter;
$d = new DateTime('2001-01-01T12:00:00-06:00');
$event = array(
'timestamp' => $d,
'message' => 'test',
'priority' => 1,
'priorityName' => 'CRIT',
'extra' => array()
);
$expected = '<logEntry><timestamp>2001-01-01T12:00:00-06:00</timestamp><message>test</message><priority>1</priority><priorityName>CRIT</priorityName></logEntry>';
$expected .= PHP_EOL . PHP_EOL;
$this->assertEquals($expected, $formatter->format($event));
}
}

0 comments on commit 17b56b8

Please sign in to comment.