/** * @group ZF-11161 */ public function testObjectsWithStringSerializationAreIncludedInFormattedString() { $options = array('rootElement' => 'log'); $event = array('message' => 'tottakai', 'priority' => 4, 'context' => array('test' => 'one'), 'reference' => new SerializableObject()); $expected = '<log><message>tottakai</message><priority>4</priority><reference>ZendTest\\Log\\TestAsset\\SerializableObject</reference></log>'; $formatter = new XmlFormatter($options); $output = $formatter->format($event); $this->assertContains($expected, $output); }
/** * @group ZF-2062 * @group ZF-4190 */ public function testFixingBrokenCharsSoXmlIsValid() { $f = new XmlFormatter(); $line = $f->format(array('message' => '&', 'priority' => 42)); $this->assertContains('&amp', $line); }
/** * @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)); }
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 XmlFormatter($options); $output = $formatter->format($event); $this->assertContains($expected, $output); $this->assertEquals('UTF-8', $formatter->getEncoding()); }