scratch – Blame information for rev 120
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
120 | 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\Formatter\LineFormatter; |
||
15 | use Monolog\Logger; |
||
16 | use Monolog\TestCase; |
||
17 | |||
18 | /** |
||
19 | * @coversDefaultClass \Monolog\Handler\FleepHookHandler |
||
20 | */ |
||
21 | class FleepHookHandlerTest extends TestCase |
||
22 | { |
||
23 | /** |
||
24 | * Default token to use in tests |
||
25 | */ |
||
26 | const TOKEN = '123abc'; |
||
27 | |||
28 | /** |
||
29 | * @var FleepHookHandler |
||
30 | */ |
||
31 | private $handler; |
||
32 | |||
33 | public function setUp() |
||
34 | { |
||
35 | parent::setUp(); |
||
36 | |||
37 | if (!extension_loaded('openssl')) { |
||
38 | $this->markTestSkipped('This test requires openssl extension to run'); |
||
39 | } |
||
40 | |||
41 | // Create instances of the handler and logger for convenience |
||
42 | $this->handler = new FleepHookHandler(self::TOKEN); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @covers ::__construct |
||
47 | */ |
||
48 | public function testConstructorSetsExpectedDefaults() |
||
49 | { |
||
50 | $this->assertEquals(Logger::DEBUG, $this->handler->getLevel()); |
||
51 | $this->assertEquals(true, $this->handler->getBubble()); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @covers ::getDefaultFormatter |
||
56 | */ |
||
57 | public function testHandlerUsesLineFormatterWhichIgnoresEmptyArrays() |
||
58 | { |
||
59 | $record = array( |
||
60 | 'message' => 'msg', |
||
61 | 'context' => array(), |
||
62 | 'level' => Logger::DEBUG, |
||
63 | 'level_name' => Logger::getLevelName(Logger::DEBUG), |
||
64 | 'channel' => 'channel', |
||
65 | 'datetime' => new \DateTime(), |
||
66 | 'extra' => array(), |
||
67 | ); |
||
68 | |||
69 | $expectedFormatter = new LineFormatter(null, null, true, true); |
||
70 | $expected = $expectedFormatter->format($record); |
||
71 | |||
72 | $handlerFormatter = $this->handler->getFormatter(); |
||
73 | $actual = $handlerFormatter->format($record); |
||
74 | |||
75 | $this->assertEquals($expected, $actual, 'Empty context and extra arrays should not be rendered'); |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * @covers ::__construct |
||
80 | */ |
||
81 | public function testConnectionStringisConstructedCorrectly() |
||
82 | { |
||
83 | $this->assertEquals('ssl://' . FleepHookHandler::FLEEP_HOST . ':443', $this->handler->getConnectionString()); |
||
84 | } |
||
85 | } |