public function testXmlValidates() { $f = new Zend_Log_Formatter_Xml(); $line = $f->format($message = 'message', $priority = 1); $sxml = @simplexml_load_string($line); $this->assertType('SimpleXMLElement', $sxml, 'Formatted XML is invalid'); }
/** * @group ZF-11161 */ public function testObjectsWithStringSerializationAreIncludedInFormattedString() { $options = array('rootElement' => 'log'); $event = array('message' => 'tottakai', 'priority' => 4, 'context' => array('test' => 'one'), 'reference' => new Zend_Log_Formatter_XmlTest_SerializableObject()); $expected = '<log><message>tottakai</message><priority>4</priority><reference>Zend_Log_Formatter_XmlTest_SerializableObject</reference></log>'; $formatter = new Zend_Log_Formatter_Xml($options); $output = $formatter->format($event); $this->assertContains($expected, $output); }
/** * @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); }
public function testConstructorWithArray() { $options = array('rootElement' => 'log', 'elementMap' => array('word' => 'message', 'priority' => 'priority')); $event = array('message' => 'tottakai', 'priority' => 4); $expected = '<log><word>tottakai</word><priority>4</priority></log>'; $formatter = new Zend_Log_Formatter_Xml($options); $output = $formatter->format($event); $this->assertContains($expected, $output); $this->assertEquals('UTF-8', $formatter->getEncoding()); }