format(array('message' => 'foo', 'priority' => 42)); $this->assertContains('foo', $line); $this->assertContains((string)42, $line); } public function testConfiguringElementMapping() { $f = new Zend_Log_Formatter_Xml('log', array('foo' => 'bar')); $line = $f->format(array('bar' => 'baz')); $this->assertContains('baz', $line); } public function testXmlDeclarationIsStripped() { $f = new Zend_Log_Formatter_Xml(); $line = $f->format(array('message' => 'foo', 'priority' => 42)); $this->assertNotContains('<\?xml version=', $line); } public function testXmlValidates() { $f = new Zend_Log_Formatter_Xml(); $line = $f->format(array('message' => 'foo', 'priority' => 42)); $sxml = @simplexml_load_string($line); $this->assertType('SimpleXMLElement', $sxml, 'Formatted XML is invalid'); } /** * @group ZF-2062 * @group ZF-4190 */ public function testHtmlSpecialCharsInMessageGetEscapedForValidXml() { $f = new Zend_Log_Formatter_Xml(); $line = $f->format(array('message' => '&key1=value1&key2=value2', 'priority' => 42)); $this->assertContains("&", $line); $this->assertTrue(substr_count($line, "&") == 2); } /** * @group ZF-2062 * @group ZF-4190 */ public function testFixingBrokenCharsSoXmlIsValid() { $f = new Zend_Log_Formatter_Xml(); $line = $f->format(array('message' => '&', 'priority' => 42)); $this->assertContains('&amp', $line); } }