ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ErrorLogHandlerTest.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
17
18function error_log()
19{
20 $GLOBALS['error_log'][] = func_get_args();
21}
22
24{
25 protected function setUp()
26 {
27 $GLOBALS['error_log'] = array();
28 }
29
36 {
37 new ErrorLogHandler(42);
38 }
39
44 {
46 $handler = new ErrorLogHandler($type);
47 $handler->setFormatter(new LineFormatter('%channel%.%level_name%: %message% %context% %extra%', null, true));
48 $handler->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz"));
49
50 $this->assertSame("test.ERROR: Foo\nBar\r\n\r\nBaz [] []", $GLOBALS['error_log'][0][0]);
51 $this->assertSame($GLOBALS['error_log'][0][1], $type);
52
53 $handler = new ErrorLogHandler($type, Logger::DEBUG, true, true);
54 $handler->setFormatter(new LineFormatter(null, null, true));
55 $handler->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz"));
56
57 $this->assertStringMatchesFormat('[%s] test.ERROR: Foo', $GLOBALS['error_log'][1][0]);
58 $this->assertSame($GLOBALS['error_log'][1][1], $type);
59
60 $this->assertStringMatchesFormat('Bar', $GLOBALS['error_log'][2][0]);
61 $this->assertSame($GLOBALS['error_log'][2][1], $type);
62
63 $this->assertStringMatchesFormat('Baz [] []', $GLOBALS['error_log'][3][0]);
64 $this->assertSame($GLOBALS['error_log'][3][1], $type);
65 }
66}
Formats incoming records into a one-line string.
testShouldLogMessagesUsingErrorLogFuncion()
@covers Monolog\Handler\ErrorLogHandler::write
testShouldNotAcceptAnInvalidTypeOnContructor()
@covers Monolog\Handler\ErrorLogHandler::__construct @expectedException InvalidArgumentException @exp...
Stores to PHP error_log() handler.
Monolog log channel.
Definition: Logger.php:28
const ERROR
Runtime errors.
Definition: Logger.php:57
const DEBUG
Detailed debug information.
Definition: Logger.php:32
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276