scratch – Blame information for rev

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  
16 /**
17 * @author Alexey Karapetov <alexey@karapetov.com>
18 */
19 class HandlerWrapperTest extends TestCase
20 {
21 /**
22 * @var HandlerWrapper
23 */
24 private $wrapper;
25  
26 private $handler;
27  
28 public function setUp()
29 {
30 parent::setUp();
31 $this->handler = $this->getMock('Monolog\\Handler\\HandlerInterface');
32 $this->wrapper = new HandlerWrapper($this->handler);
33 }
34  
35 /**
36 * @return array
37 */
38 public function trueFalseDataProvider()
39 {
40 return array(
41 array(true),
42 array(false),
43 );
44 }
45  
46 /**
47 * @param $result
48 * @dataProvider trueFalseDataProvider
49 */
50 public function testIsHandling($result)
51 {
52 $record = $this->getRecord();
53 $this->handler->expects($this->once())
54 ->method('isHandling')
55 ->with($record)
56 ->willReturn($result);
57  
58 $this->assertEquals($result, $this->wrapper->isHandling($record));
59 }
60  
61 /**
62 * @param $result
63 * @dataProvider trueFalseDataProvider
64 */
65 public function testHandle($result)
66 {
67 $record = $this->getRecord();
68 $this->handler->expects($this->once())
69 ->method('handle')
70 ->with($record)
71 ->willReturn($result);
72  
73 $this->assertEquals($result, $this->wrapper->handle($record));
74 }
75  
76 /**
77 * @param $result
78 * @dataProvider trueFalseDataProvider
79 */
80 public function testHandleBatch($result)
81 {
82 $records = $this->getMultipleRecords();
83 $this->handler->expects($this->once())
84 ->method('handleBatch')
85 ->with($records)
86 ->willReturn($result);
87  
88 $this->assertEquals($result, $this->wrapper->handleBatch($records));
89 }
90  
91 public function testPushProcessor()
92 {
93 $processor = function () {};
94 $this->handler->expects($this->once())
95 ->method('pushProcessor')
96 ->with($processor);
97  
98 $this->assertEquals($this->wrapper, $this->wrapper->pushProcessor($processor));
99 }
100  
101 public function testPopProcessor()
102 {
103 $processor = function () {};
104 $this->handler->expects($this->once())
105 ->method('popProcessor')
106 ->willReturn($processor);
107  
108 $this->assertEquals($processor, $this->wrapper->popProcessor());
109 }
110  
111 public function testSetFormatter()
112 {
113 $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
114 $this->handler->expects($this->once())
115 ->method('setFormatter')
116 ->with($formatter);
117  
118 $this->assertEquals($this->wrapper, $this->wrapper->setFormatter($formatter));
119 }
120  
121 public function testGetFormatter()
122 {
123 $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
124 $this->handler->expects($this->once())
125 ->method('getFormatter')
126 ->willReturn($formatter);
127  
128 $this->assertEquals($formatter, $this->wrapper->getFormatter());
129 }
130 }