Skip to content

Commit 0487e10

Browse files
minor symfony#32592 [Debug] Use mocks before replacing the error handler (greg0ire)
This PR was merged into the 3.4 branch. Discussion ---------- [Debug] Use mocks before replacing the error handler | Q | A | ------------- | --- | Branch? | 3.4, | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a We want the bridge to mute the php 7.4 deprecations triggered when building mocks. Commits ------- f6e0b01 Use mocks before replacing the error handler
2 parents 04b9ce3 + f6e0b01 commit 0487e10

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)