ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
HandlerWrapperTest.php
Go to the documentation of this file.
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
12namespace Monolog\Handler;
13
15
20{
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
38 public function trueFalseDataProvider()
39 {
40 return array(
41 array(true),
42 array(false),
43 );
44 }
45
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
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
80 public function testHandleBatch($result)
81 {
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}
$result
An exception for terminatinating execution or to throw for unit testing.
This simple wrapper class can be used to extend handlers functionality.
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
$records
Definition: simple_test.php:22