예제 #1
0
    public function testFormat()
    {
        $event = array('timestamp' => '2012-06-12T09:00:00+02:00', 'message' => 'test', 'priority' => 1, 'priorityName' => 'CRIT', 'extra' => array('file' => 'test.php', 'line' => 1, 'trace' => array(array('file' => 'test.php', 'line' => 1, 'function' => 'test', 'class' => 'Test', 'type' => '::', 'args' => array(1)), array('file' => 'test.php', 'line' => 2, 'function' => 'test', 'class' => 'Test', 'type' => '::', 'args' => array(1)))));
        $expected = <<<EOF
2012-06-12T09:00:00+02:00 CRIT (1) test in test.php on line 1
[Trace]
File  : test.php
Line  : 1
Func  : test
Class : Test
Type  : static
Args  : Array
(
    [0] => 1
)

File  : test.php
Line  : 2
Func  : test
Class : Test
Type  : static
Args  : Array
(
    [0] => 1
)


EOF;
        $formatter = new ExceptionHandler();
        $output = $formatter->format($event);
        $this->assertEquals($expected, $output);
    }
예제 #2
0
 public function testFormat()
 {
     $date = new DateTime();
     $event = array('timestamp' => $date, 'message' => 'test', 'priority' => 1, 'priorityName' => 'CRIT', 'extra' => array('file' => 'test.php', 'line' => 1, 'trace' => array(array('file' => 'test.php', 'line' => 1, 'function' => 'test', 'class' => 'Test', 'type' => '::', 'args' => array(1)), array('file' => 'test.php', 'line' => 2, 'function' => 'test', 'class' => 'Test', 'type' => '::', 'args' => array(1)))));
     // The formatter ends with unix style line endings so make sure we expect that
     // output as well:
     $expected = $date->format('c') . " CRIT (1) test in test.php on line 1\n";
     $expected .= "[Trace]\n";
     $expected .= "File  : test.php\n";
     $expected .= "Line  : 1\n";
     $expected .= "Func  : test\n";
     $expected .= "Class : Test\n";
     $expected .= "Type  : static\n";
     $expected .= "Args  : Array\n";
     $expected .= "(\n";
     $expected .= "    [0] => 1\n";
     $expected .= ")\n\n";
     $expected .= "File  : test.php\n";
     $expected .= "Line  : 2\n";
     $expected .= "Func  : test\n";
     $expected .= "Class : Test\n";
     $expected .= "Type  : static\n";
     $expected .= "Args  : Array\n";
     $expected .= "(\n";
     $expected .= "    [0] => 1\n";
     $expected .= ")\n\n";
     $formatter = new ExceptionHandler();
     $output = $formatter->format($event);
     $this->assertEquals($expected, $output);
 }
예제 #3
0
    public function testFormat()
    {
        $date = date('c');
        $event = array(
            'timestamp'    => $date,
            'message'      => 'test',
            'priority'     => 1,
            'priorityName' => 'CRIT',
            'extra' => array (
                'file'  => 'test.php',
                'line'  => 1,
                'trace' => array(array(
                    'file'     => 'test.php',
                    'line'     => 1,
                    'function' => 'test',
                    'class'    => 'Test',
                    'type'     => '::',
                    'args'     => array(1)
                ))
            )
        );
        $formatter = new ExceptionHandler();
        $output = $formatter->format($event);

        $this->assertEquals($date . " CRIT (1) test in test.php on line 1\n" .
                "[Trace]\nFile  : test.php\nLine  : 1\nFunc  : test\nClass : Test\n" .
                "Type  : static\nArgs  : Array\n(\n    [0] => 1\n)\n\n", $output);
    }