Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 73d3770

Browse filesBrowse files
committed
feature #12731 [Monolog Bridge] Remove deprecated log methods + add unit tests (FlorianLB)
This PR was squashed before being merged into the 3.0-dev branch (closes #12731). Discussion ---------- [Monolog Bridge] Remove deprecated log methods + add unit tests | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | -- | License | MIT | Doc PR | -- Remove deprecated methods. I took the opportunity to add some missing unit tests. Commits ------- 9ecfc84 [Monolog Bridge] Remove deprecated log methods + add unit tests
2 parents cc3b2de + 9ecfc84 commit 73d3770
Copy full SHA for 73d3770

File tree

3 files changed

+69
-40
lines changed
Filter options

3 files changed

+69
-40
lines changed

‎UPGRADE-3.0.md

Copy file name to clipboardExpand all lines: UPGRADE-3.0.md
+8Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Monolog/Logger.php
-40Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -22,46 +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-
trigger_error('The emerg() method of the Monolog Logger was removed. You should use the new method emergency() instead, which is PSR-3 compatible.', E_USER_DEPRECATED);
31-
32-
return parent::addRecord(BaseLogger::EMERGENCY, $message, $context);
33-
}
34-
35-
/**
36-
* @deprecated since 2.2, to be removed in 3.0. Use critical() which is PSR-3 compatible.
37-
*/
38-
public function crit($message, array $context = array())
39-
{
40-
trigger_error('The crit() method of the Monolog Logger was removed. You should use the new method critical() instead, which is PSR-3 compatible.', E_USER_DEPRECATED);
41-
42-
return parent::addRecord(BaseLogger::CRITICAL, $message, $context);
43-
}
44-
45-
/**
46-
* @deprecated since 2.2, to be removed in 3.0. Use error() which is PSR-3 compatible.
47-
*/
48-
public function err($message, array $context = array())
49-
{
50-
trigger_error('The err() method of the Monolog Logger was removed. You should use the new method error() instead, which is PSR-3 compatible.', E_USER_DEPRECATED);
51-
52-
return parent::addRecord(BaseLogger::ERROR, $message, $context);
53-
}
54-
55-
/**
56-
* @deprecated since 2.2, to be removed in 3.0. Use warning() which is PSR-3 compatible.
57-
*/
58-
public function warn($message, array $context = array())
59-
{
60-
trigger_error('The warn() method of the Monolog Logger was removed. You should use the new method warning() instead, which is PSR-3 compatible.', E_USER_DEPRECATED);
61-
62-
return parent::addRecord(BaseLogger::WARNING, $message, $context);
63-
}
64-
6525
/**
6626
* @see Symfony\Component\HttpKernel\Log\DebugLoggerInterface
6727
*/
+61Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.