Skip to content

Commit

Permalink
minor #32592 [Debug] Use mocks before replacing the error handler (gr…
Browse files Browse the repository at this point in the history
…eg0ire)

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
  • Loading branch information
nicolas-grekas committed Jul 18, 2019
2 parents 04b9ce3 + f6e0b01 commit 0487e10
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php
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 @@ -334,12 +333,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 @@ -483,6 +481,7 @@ public function testSettingLoggerWhenExceptionIsBuffered()
public function testHandleFatalError()
{
try {
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$handler = ErrorHandler::register();

$error = [
Expand All @@ -492,8 +491,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 0487e10

Please sign in to comment.