scratch – Blame information for rev 115

Subversion Repositories:
Rev:
Rev Author Line No. Line
115 office 1 <?php
2  
3 /*
4 * This file is part of the Monolog package.
5 *
6 * (c) Jordi Boggiano <j.boggiano@seld.be>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11  
12 namespace Monolog\Handler;
13  
14 use Monolog\TestCase;
15 use Monolog\Logger;
16  
17 /**
18 * @covers Monolog\Handler\FirePHPHandler
19 */
20 class FirePHPHandlerTest extends TestCase
21 {
22 public function setUp()
23 {
24 TestFirePHPHandler::reset();
25 $_SERVER['HTTP_USER_AGENT'] = 'Monolog Test; FirePHP/1.0';
26 }
27  
28 public function testHeaders()
29 {
30 $handler = new TestFirePHPHandler;
31 $handler->setFormatter($this->getIdentityFormatter());
32 $handler->handle($this->getRecord(Logger::DEBUG));
33 $handler->handle($this->getRecord(Logger::WARNING));
34  
35 $expected = array(
36 'X-Wf-Protocol-1' => 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2',
37 'X-Wf-1-Structure-1' => 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1',
38 'X-Wf-1-Plugin-1' => 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3',
39 'X-Wf-1-1-1-1' => 'test',
40 'X-Wf-1-1-1-2' => 'test',
41 );
42  
43 $this->assertEquals($expected, $handler->getHeaders());
44 }
45  
46 public function testConcurrentHandlers()
47 {
48 $handler = new TestFirePHPHandler;
49 $handler->setFormatter($this->getIdentityFormatter());
50 $handler->handle($this->getRecord(Logger::DEBUG));
51 $handler->handle($this->getRecord(Logger::WARNING));
52  
53 $handler2 = new TestFirePHPHandler;
54 $handler2->setFormatter($this->getIdentityFormatter());
55 $handler2->handle($this->getRecord(Logger::DEBUG));
56 $handler2->handle($this->getRecord(Logger::WARNING));
57  
58 $expected = array(
59 'X-Wf-Protocol-1' => 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2',
60 'X-Wf-1-Structure-1' => 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1',
61 'X-Wf-1-Plugin-1' => 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3',
62 'X-Wf-1-1-1-1' => 'test',
63 'X-Wf-1-1-1-2' => 'test',
64 );
65  
66 $expected2 = array(
67 'X-Wf-1-1-1-3' => 'test',
68 'X-Wf-1-1-1-4' => 'test',
69 );
70  
71 $this->assertEquals($expected, $handler->getHeaders());
72 $this->assertEquals($expected2, $handler2->getHeaders());
73 }
74 }
75  
76 class TestFirePHPHandler extends FirePHPHandler
77 {
78 protected $headers = array();
79  
80 public static function reset()
81 {
82 self::$initialized = false;
83 self::$sendHeaders = true;
84 self::$messageIndex = 1;
85 }
86  
87 protected function sendHeader($header, $content)
88 {
89 $this->headers[$header] = $content;
90 }
91  
92 public function getHeaders()
93 {
94 return $this->headers;
95 }
96 }