Skip to content

Commit

Permalink
Use mocks before replacing the error handler
Browse files Browse the repository at this point in the history
We want the bridge to mute the deprecations triggered when building mocks.
  • Loading branch information
greg0ire committed Jul 17, 2019
1 parent 3c568f2 commit 0568680
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public function testRegister()

public function testErrorGetLast()
{
$handler = ErrorHandler::register();
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$handler = ErrorHandler::register();
$handler->setDefaultLogger($logger);
$handler->screamAt(E_ALL);

Expand Down Expand Up @@ -143,9 +143,8 @@ public function testConstruct()
public function testDefaultLogger()
{
try {
$handler = ErrorHandler::register();

$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$handler = ErrorHandler::register();

$handler->setDefaultLogger($logger, E_NOTICE);
$handler->setDefaultLogger($logger, [E_USER_NOTICE => LogLevel::CRITICAL]);
Expand Down Expand Up @@ -331,12 +330,11 @@ public function testHandleDeprecation()
public function testHandleException()
{
try {
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$handler = ErrorHandler::register();

$exception = new \Exception('foo');

$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();

$logArgCheck = function ($level, $message, $context) {
$this->assertSame('Uncaught Exception: foo', $message);
$this->assertArrayHasKey('exception', $context);
Expand Down Expand Up @@ -442,6 +440,7 @@ public function testSettingLoggerWhenExceptionIsBuffered()
public function testHandleFatalError()
{
try {
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$handler = ErrorHandler::register();

$error = [
Expand All @@ -451,8 +450,6 @@ public function testHandleFatalError()
'line' => 123,
];

$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();

$logArgCheck = function ($level, $message, $context) {
$this->assertEquals('Fatal Parse Error: foo', $message);
$this->assertArrayHasKey('exception', $context);
Expand Down

0 comments on commit 0568680

Please sign in to comment.