8000 [Monolog Bridge] Remove deprecated log methods + add unit tests · symfony/symfony@9ecfc84 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9ecfc84

Browse files
FlorianLBfabpot
FlorianLB
authored andcommitted
[Monolog Bridge] Remove deprecated log methods + add unit tests
1 parent b2e7ca3 commit 9ecfc84

File tree

3 files changed

+69
-32
lines changed

3 files changed

+69
-32
lines changed

UPGRADE-3.0.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,3 +998,11 @@ UPGRADE FROM 2.x to 3.0
998998
* `Process::setStdin()` and `Process::getStdin()` have been removed. Use
999999
`Process::setInput()` and `Process::getInput()` that works the same way.
10001000
* `Process::setInput()` and `ProcessBuilder::setInput()` do not accept non-scalar types.
1001+
1002+
### Monolog Bridge
1003+
1004+
* `Symfony\Bridge\Monolog\Logger::emerg()` was removed. Use `emergency()` which is PSR-3 compatible.
1005+
* `Symfony\Bridge\Monolog\Logger::crit()` was removed. Use `critical()` which is PSR-3 compatible.
1006+
* `Symfony\Bridge\Monolog\Logger::err()` was removed. Use `error()` which is PSR-3 compatible.
1007+
* `Symfony\Bridge\Monolog\Logger::warn()` was removed. Use `warning()` which is PSR-3 compatible.
1008+

src/Symfony/Bridge/Monolog/Logger.php

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,38 +22,6 @@
2222
*/
2323
class Logger extends BaseLogger implements LoggerInterface, DebugLoggerInterface
2424
{
25-
/**
26-
* @deprecated since 2.2, to be removed in 3.0. Use emergency() which is PSR-3 compatible.
27-
*/
28-
public function emerg($message, array $context = array())
29-
{
30-
return parent::addRecord(BaseLogger::EMERGENCY, $message, $context);
31-
}
32-
33-
/**
34-
* @deprecated since 2.2, to be removed in 3.0. Use critical() which is PSR-3 compatible.
35-
*/
36-
public function crit($message, array $context = array())
37-
{
38-
return parent::addRecord(BaseLogger::CRITICAL, $message, $context);
39-
}
40-
41-
/**
42-
* @deprecated since 2.2, to be removed in 3.0. Use error() which is PSR-3 compatible.
43-
*/
44-
public function err($message, array $context = array())
45-
{
46-
return parent::addRecord(BaseLogger::ERROR, $message, $context);
47-
}
48-
49-
/**
50-
* @deprecated since 2.2, to be removed in 3.0. Use warning() which is PSR-3 compatible.
51-
*/
52-
public function warn($message, array $context = array())
53-
{
54-
return parent::addRecord(BaseLogger::WARNING, $message, $context);
55-
}
56-
5725
/**
5826
* @see Symfony\Component\HttpKernel\Log\DebugLoggerInterface
5927
*/
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
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 Symfony\Bridge\Monolog\Tests;
13+
14+
use Symfony\Bridge\Monolog\Logger;
15+
16+
class LoggerTest extends \PHPUnit_Framework_TestCase
17+
{
18+
public function testGetLogsWithDebugHandler()
19+
{
20+
$expectedLogs = array('foo', 'bar');
21+
22+
$debugHandler = $this->getMock('Symfony\Component\HttpKernel\Log\DebugLoggerInterface');
23+
$debugHandler
24+
->expects($this->any())
25+
->method('getLogs')
26+
->will($this->returnValue($expectedLogs))
27+
;
28+
29+
$logger = new Logger('foobar', array($debugHandler));
30+
$this->assertEquals($expectedLogs, $logger->getLogs());
31+
}
32+
33+
public function testGetLogsWithoutDebugHandler()
34+
{
35+
$handler = $this->getMock('Symfony\Component\HttpKernel\Log\LoggerInterface');
36+
37+
$logger = new Logger('foobar', array($handler));
38+
$this->assertEquals(array(), $logger->getLogs());
39+
}
40+
41+
public function testCountErrorsWithDebugHandler()
42+
{
43+
$debugHandler = $this->getMock('Symfony\Component\HttpKernel\Log\DebugLoggerInterface');
44+
$debugHandler
45+
->expects($this->any())
46+
->method('countErrors')
47+
->will($this->returnValue(5))
48+
;
49+
50+
$logger = new Logger('foobar', array($debugHandler));
51+
$this->assertEquals(5, $logger->countErrors());
52+
}
53+
54+
public function testCountErrorsWithoutDebugHandler()
55+
{
56+
$handler = $this->getMock('Symfony\Component\HttpKernel\Log\LoggerInterface');
57+
58+
$logger = new Logger('foobar', array($handler));
59+
$this->assertEquals(0, $logger->countErrors());
60+
}
61+
}

0 commit comments

Comments
 (0)
0