ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
AbstractHandlerTest.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
18
20{
30 public function testConstructAndGetSet()
31 {
32 $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', array(Logger::WARNING, false));
33 $this->assertEquals(Logger::WARNING, $handler->getLevel());
34 $this->assertEquals(false, $handler->getBubble());
35
36 $handler->setLevel(Logger::ERROR);
37 $handler->setBubble(true);
38 $handler->setFormatter($formatter = new LineFormatter);
39 $this->assertEquals(Logger::ERROR, $handler->getLevel());
40 $this->assertEquals(true, $handler->getBubble());
41 $this->assertSame($formatter, $handler->getFormatter());
42 }
43
47 public function testHandleBatch()
48 {
49 $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler');
50 $handler->expects($this->exactly(2))
51 ->method('handle');
52 $handler->handleBatch(array($this->getRecord(), $this->getRecord()));
53 }
54
58 public function testIsHandling()
59 {
60 $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', array(Logger::WARNING, false));
61 $this->assertTrue($handler->isHandling($this->getRecord()));
62 $this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG)));
63 }
64
68 public function testHandlesPsrStyleLevels()
69 {
70 $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', array('warning', false));
71 $this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG)));
72 $handler->setLevel('debug');
73 $this->assertTrue($handler->isHandling($this->getRecord(Logger::DEBUG)));
74 }
75
81 {
82 $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler');
83 $this->assertInstanceOf('Monolog\Formatter\LineFormatter', $handler->getFormatter());
84 }
85
91 public function testPushPopProcessor()
92 {
93 $logger = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler');
94 $processor1 = new WebProcessor;
95 $processor2 = new WebProcessor;
96
97 $logger->pushProcessor($processor1);
98 $logger->pushProcessor($processor2);
99
100 $this->assertEquals($processor2, $logger->popProcessor());
101 $this->assertEquals($processor1, $logger->popProcessor());
102 $logger->popProcessor();
103 }
104
110 {
111 $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler');
112
113 $handler->pushProcessor(new \stdClass());
114 }
115}
Formats incoming records into a one-line string.
testConstructAndGetSet()
@covers Monolog\Handler\AbstractHandler::__construct @covers Monolog\Handler\AbstractHandler::getLeve...
testGetFormatterInitializesDefault()
@covers Monolog\Handler\AbstractHandler::getFormatter @covers Monolog\Handler\AbstractHandler::getDef...
testIsHandling()
@covers Monolog\Handler\AbstractHandler::isHandling
testPushPopProcessor()
@covers Monolog\Handler\AbstractHandler::pushProcessor @covers Monolog\Handler\AbstractHandler::popPr...
testPushProcessorWithNonCallable()
@covers Monolog\Handler\AbstractHandler::pushProcessor @expectedException InvalidArgumentException
testHandlesPsrStyleLevels()
@covers Monolog\Handler\AbstractHandler::__construct
testHandleBatch()
@covers Monolog\Handler\AbstractHandler::handleBatch
Monolog log channel.
Definition: Logger.php:28
const ERROR
Runtime errors.
Definition: Logger.php:57
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:52
const DEBUG
Detailed debug information.
Definition: Logger.php:32
Injects url/method and remote IP of the current web request in all records.
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19