ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
12 namespace Monolog\Handler;
13 
15 use Monolog\Logger;
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 }
const DEBUG
Detailed debug information.
Definition: Logger.php:32
const ERROR
Runtime errors.
Definition: Logger.php:57
testPushProcessorWithNonCallable()
Monolog::pushProcessor InvalidArgumentException
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
testGetFormatterInitializesDefault()
Monolog::getFormatter Monolog::getDefaultFormatter
testHandlesPsrStyleLevels()
Monolog::__construct
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:52
Create styles array
The data for the language used.
testConstructAndGetSet()
Monolog::__construct Monolog::getLevel Monolog::setLevel Monolog::getBubble Monolog::setBubble M...
testPushPopProcessor()
Monolog::pushProcessor Monolog::popProcessor LogicException
Formats incoming records into a one-line string.