2011-04-22 14:12:12 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of the Monolog package.
|
|
|
|
*
|
|
|
|
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Monolog\Handler;
|
|
|
|
|
|
|
|
use Monolog\TestCase;
|
|
|
|
use Monolog\Logger;
|
|
|
|
|
2011-06-29 20:23:08 +02:00
|
|
|
/**
|
|
|
|
* @covers Monolog\Handler\FirePHPHandler
|
|
|
|
*/
|
2011-04-22 14:12:12 -07:00
|
|
|
class FirePHPHandlerTest extends TestCase
|
|
|
|
{
|
2011-04-25 15:48:52 +02:00
|
|
|
public function setUp()
|
2011-04-22 14:12:12 -07:00
|
|
|
{
|
2011-04-25 15:48:52 +02:00
|
|
|
TestFirePHPHandler::reset();
|
2011-04-22 14:12:12 -07:00
|
|
|
}
|
|
|
|
|
2011-04-25 15:48:52 +02:00
|
|
|
public function testHeaders()
|
2011-04-22 14:12:12 -07:00
|
|
|
{
|
2011-04-25 15:48:52 +02:00
|
|
|
$handler = new TestFirePHPHandler;
|
2011-08-03 00:11:08 +04:00
|
|
|
$handler->setFormatter($this->getIdentityFormatter());
|
2011-04-25 15:48:52 +02:00
|
|
|
$handler->handle($this->getRecord(Logger::DEBUG));
|
|
|
|
$handler->handle($this->getRecord(Logger::WARNING));
|
2011-04-23 15:33:39 -07:00
|
|
|
|
2011-04-25 15:48:52 +02:00
|
|
|
$expected = array(
|
|
|
|
'X-Wf-Protocol-1' => 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2',
|
|
|
|
'X-Wf-1-Structure-1' => 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1',
|
2011-05-16 22:49:49 +02:00
|
|
|
'X-Wf-1-Plugin-1' => 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3',
|
2011-08-03 00:11:08 +04:00
|
|
|
'X-Wf-1-1-1-1' => 'test',
|
|
|
|
'X-Wf-1-1-1-2' => 'test',
|
2011-04-25 15:48:52 +02:00
|
|
|
);
|
2011-04-22 14:12:12 -07:00
|
|
|
|
2011-04-25 15:48:52 +02:00
|
|
|
$this->assertEquals($expected, $handler->getHeaders());
|
2011-04-23 15:33:39 -07:00
|
|
|
}
|
|
|
|
|
2011-04-25 15:48:52 +02:00
|
|
|
public function testConcurrentHandlers()
|
2011-04-23 15:33:39 -07:00
|
|
|
{
|
2011-04-25 15:48:52 +02:00
|
|
|
$handler = new TestFirePHPHandler;
|
2011-08-03 00:11:08 +04:00
|
|
|
$handler->setFormatter($this->getIdentityFormatter());
|
2011-04-23 15:33:39 -07:00
|
|
|
$handler->handle($this->getRecord(Logger::DEBUG));
|
2011-04-25 15:48:52 +02:00
|
|
|
$handler->handle($this->getRecord(Logger::WARNING));
|
2011-04-23 15:33:39 -07:00
|
|
|
|
2011-04-25 15:48:52 +02:00
|
|
|
$handler2 = new TestFirePHPHandler;
|
2011-08-03 00:11:08 +04:00
|
|
|
$handler2->setFormatter($this->getIdentityFormatter());
|
2011-04-25 15:48:52 +02:00
|
|
|
$handler2->handle($this->getRecord(Logger::DEBUG));
|
|
|
|
$handler2->handle($this->getRecord(Logger::WARNING));
|
|
|
|
|
|
|
|
$expected = array(
|
2011-04-23 17:52:32 -07:00
|
|
|
'X-Wf-Protocol-1' => 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2',
|
|
|
|
'X-Wf-1-Structure-1' => 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1',
|
2011-05-16 22:49:49 +02:00
|
|
|
'X-Wf-1-Plugin-1' => 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3',
|
2011-08-03 00:11:08 +04:00
|
|
|
'X-Wf-1-1-1-1' => 'test',
|
|
|
|
'X-Wf-1-1-1-2' => 'test',
|
2011-04-23 15:33:39 -07:00
|
|
|
);
|
2011-04-25 15:48:52 +02:00
|
|
|
|
|
|
|
$expected2 = array(
|
2011-08-03 00:11:08 +04:00
|
|
|
'X-Wf-1-1-1-3' => 'test',
|
|
|
|
'X-Wf-1-1-1-4' => 'test',
|
2011-04-25 15:48:52 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $handler->getHeaders());
|
|
|
|
$this->assertEquals($expected2, $handler2->getHeaders());
|
2011-04-23 15:33:39 -07:00
|
|
|
}
|
2011-04-25 15:48:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class TestFirePHPHandler extends FirePHPHandler
|
|
|
|
{
|
|
|
|
protected $headers = array();
|
2011-04-23 15:33:39 -07:00
|
|
|
|
2011-04-25 15:48:52 +02:00
|
|
|
public static function reset()
|
2011-04-22 14:12:12 -07:00
|
|
|
{
|
2011-04-25 15:48:52 +02:00
|
|
|
self::$initialized = false;
|
|
|
|
self::$messageIndex = 1;
|
2011-04-22 14:12:12 -07:00
|
|
|
}
|
|
|
|
|
2011-04-25 15:48:52 +02:00
|
|
|
protected function sendHeader($header, $content)
|
2011-04-22 14:12:12 -07:00
|
|
|
{
|
2011-04-25 15:48:52 +02:00
|
|
|
$this->headers[$header] = $content;
|
2011-04-22 14:12:12 -07:00
|
|
|
}
|
2011-04-25 15:48:52 +02:00
|
|
|
|
|
|
|
public function getHeaders()
|
|
|
|
{
|
|
|
|
return $this->headers;
|
|
|
|
}
|
2012-06-14 15:46:17 +02:00
|
|
|
}
|