Skip to content

Commit f6e0b01

Browse files
committed
Use mocks before replacing the error handler
We want the bridge to mute the deprecations triggered when building mocks.
1 parent 04b9ce3 commit f6e0b01

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php

+4-7
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ public function testRegister()
7070

7171
public function testErrorGetLast()
7272
{
73-
$handler = ErrorHandler::register();
7473
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
74+
$handler = ErrorHandler::register();
7575
$handler->setDefaultLogger($logger);
7676
$handler->screamAt(E_ALL);
7777

@@ -143,9 +143,8 @@ public function testConstruct()
143143
public function testDefaultLogger()
144144
{
145145
try {
146-
$handler = ErrorHandler::register();
147-
148146
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
147+
$handler = ErrorHandler::register();
149148

150149
$handler->setDefaultLogger($logger, E_NOTICE);
151150
$handler->setDefaultLogger($logger, [E_USER_NOTICE => LogLevel::CRITICAL]);
@@ -334,12 +333,11 @@ public function testHandleDeprecation()
334333
public function testHandleException()
335334
{
336335
try {
336+
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
337337
$handler = ErrorHandler::register();
338338

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

341-
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
342-
343341
$logArgCheck = function ($level, $message, $context) {
344342
$this->assertSame('Uncaught Exception: foo', $message);
345343
$this->assertArrayHasKey('exception', $context);
@@ -483,6 +481,7 @@ public function testSettingLoggerWhenExceptionIsBuffered()
483481
public function testHandleFatalError()
484482
{
485483
try {
484+
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
486485
$handler = ErrorHandler::register();
487486

488487
$error = [
@@ -492,8 +491,6 @@ public function testHandleFatalError()
492491
'line' => 123,
493492
];
494493

495-
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
496-
497494
$logArgCheck = function ($level, $message, $context) {
498495
$this->assertEquals('Fatal Parse Error: foo', $message);
499496
$this->assertArrayHasKey('exception', $context);

0 commit comments

Comments
 (0)