8000 [Monolog Bridge] Remove deprecated log methods + add unit tests by FlorianLB · Pull Request #12731 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Monolog Bridge] Remove deprecated log methods + add unit tests #12731 8000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions UPGRADE-3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -998,3 +998,11 @@ UPGRADE FROM 2.x to 3.0
* `Process::setStdin()` and `Process::getStdin()` have been removed. Use
`Process::setInput()` and `Process::getInput()` that works the same way.
* `Process::setInput()` and `ProcessBuilder::setInput()` do not accept non-scalar types.

### Monolog Bridge

* `Symfony\Bridge\Monolog\Logger::emerg()` was removed. Use `emergency()` which is PSR-3 compatible.
* `Symfony\Bridge\Monolog\Logger::crit()` was removed. Use `critical()` which is PSR-3 compatible.
* `Symfony\Bridge\Monolog\Logger::err()` was removed. Use `error()` which is PSR-3 compatible.
* `Symfony\Bridge\Monolog\Logger::warn()` was removed. Use `warning()` which is PSR-3 compatible.

32 changes: 0 additions & 32 deletions src/Symfony/Bridge/Monolog/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,6 @@
*/
class Logger extends BaseLogger implements LoggerInterface, DebugLoggerInterface
{
/**
* @deprecated since 2.2, to be removed in 3.0. Use emergency() which is PSR-3 compatible.
*/
public function emerg($message, array $context = array())
{
return parent::addRecord(BaseLogger::EMERGENCY, $message, $context);
}

/**
* @deprecated since 2.2, to be removed in 3.0. Use critical() which is PSR-3 compatible.
*/
public function crit($message, array $context = array())
{
return parent::addRecord(BaseLogger::CRITICAL, $message, $context);
}

/**
* @deprecated since 2.2, to be removed in 3.0. Use error() which is PSR-3 compatible.
*/
public function err($message, array $context = array())
{
return parent::addRecord(BaseLogger::ERROR, $message, $context);
}

/**
* @deprecated since 2.2, to be removed in 3.0. Use warning() which is PSR-3 compatible.
*/
public function warn($message, array $context = array())
{
return parent::addRecord(BaseLogger::WARNING, $message, $context);
}

/**
* @see Symfony\Component\HttpKernel\Log\DebugLoggerInterface
*/
Expand Down
61 changes: 61 additions & 0 deletions src/Symfony/Bridge/Monolog/Tests/LoggerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bridge\Monolog\Tests;

use Symfony\Bridge\Monolog\Logger;

class LoggerTest extends \PHPUnit_Framework_TestCase
{
public function testGetLogsWithDebugHandler()
{
$expectedLogs = array('foo', 'bar');

$debugHandler = $this->getMock('Symfony\Component\HttpKernel\Log\DebugLoggerInterface');
$debugHandler
->expects($this->any())
->method('getLogs')
->will($this->returnValue($expectedLogs))
;

$logger = new Logger('foobar', array($debugHandler));
$this->assertEquals($expectedLogs, $logger->getLogs());
}

public function testGetLogsWithoutDebugHandler()
{
$handler = $this->getMock('Symfony\Component\HttpKernel\Log\LoggerInterface');

$logger = new Logger('foobar', array($handler));
$this->assertEquals(array(), $logger->getLogs());
}

public function testCountErrorsWithDebugHandler()
{
$debugHandler = $this->getMock('Symfony\Component\HttpKernel\Log\DebugLoggerInterface');
$debugHandler
->expects($this->any())
->method('countErrors')
->will($this->returnValue(5))
;

$logger = new Logger('foobar', array($debugHandler));
$this->assertEquals(5, $logger->countErrors());
}

public function testCountErrorsWithoutDebugHandler()
{
$handler = $this->getMock('Symfony\Component\HttpKernel\Log\LoggerInterface');

$logger = new Logger('foobar', array($handler));
$this->assertEquals(0, $logger->countErrors());
}
}
0