Skip to content

Commit c2bdf8d

Browse files
Merge branch '4.4' into 5.1
* 4.4: Use createMock() and use import instead of FQCN
2 parents 15713e5 + d603654 commit c2bdf8d

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

Tests/DebugClassLoaderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\ErrorHandler\Tests;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\ErrorHandler\Tests\Fixtures\ExtendsDeprecatedParent;
1516
use Symfony\Component\ErrorHandler\DebugClassLoader;
1617

1718
class DebugClassLoaderTest extends TestCase
@@ -176,7 +177,7 @@ public function testDeprecatedSuperInSameNamespace()
176177
$e = error_reporting(0);
177178
trigger_error('', E_USER_NOTICE);
178179

179-
class_exists(\Symfony\Bridge\ErrorHandler\Tests\Fixtures\ExtendsDeprecatedParent::class, true);
180+
class_exists(ExtendsDeprecatedParent::class, true);
180181

181182
error_reporting($e);
182183
restore_error_handler();

Tests/ErrorHandlerTest.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\ErrorHandler\Tests;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Psr\Log\LoggerInterface;
1516
use Psr\Log\LogLevel;
1617
use Psr\Log\NullLogger;
1718
use Symfony\Component\ErrorHandler\BufferingLogger;
@@ -62,7 +63,7 @@ public function testRegister()
6263

6364
public function testErrorGetLast()
6465
{
65-
$logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
66+
$logger = $this->createMock(LoggerInterface::class);
6667
$handler = ErrorHandler::register();
6768
$handler->setDefaultLogger($logger);
6869
$handler->screamAt(\E_ALL);
@@ -194,7 +195,7 @@ public function testConstruct()
194195
public function testDefaultLogger()
195196
{
196197
try {
197-
$logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
198+
$logger = $this->createMock(LoggerInterface::class);
198199
$handler = ErrorHandler::register();
199200

200201
$handler->setDefaultLogger($logger, \E_NOTICE);
@@ -269,7 +270,7 @@ public function testHandleError()
269270
restore_error_handler();
270271
restore_exception_handler();
271272

272-
$logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
273+
$logger = $this->createMock(LoggerInterface::class);
273274

274275
$warnArgCheck = function ($logLevel, $message, $context) {
275276
$this->assertEquals('info', $logLevel);
@@ -294,7 +295,7 @@ public function testHandleError()
294295
restore_error_handler();
295296
restore_exception_handler();
296297

297-
$logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
298+
$logger = $this->createMock(LoggerInterface::class);
298299

299300
$line = null;
300301
$logArgCheck = function ($level, $message, $context) use (&$line) {
@@ -395,7 +396,7 @@ public function testHandleDeprecation()
395396
$this->assertSame('User Deprecated: Foo deprecation', $exception->getMessage());
396397
};
397398

398-
$logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
399+
$logger = $this->createMock(LoggerInterface::class);
399400
$logger
400401
->expects($this->once())
401402
->method('log')
@@ -413,7 +414,7 @@ public function testHandleDeprecation()
413414
public function testHandleException(string $expectedMessage, \Throwable $exception)
414415
{
415416
try {
416-
$logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
417+
$logger = $this->createMock(LoggerInterface::class);
417418
$handler = ErrorHandler::register();
418419

419420
$logArgCheck = function ($level, $message, $context) use ($expectedMessage, $exception) {
@@ -505,7 +506,7 @@ public function testBootstrappingLogger()
505506

506507
$bootLogger->log(LogLevel::WARNING, 'Foo message', ['exception' => $exception]);
507508

508-
$mockLogger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
509+
$mockLogger = $this->createMock(LoggerInterface::class);
509510
$mockLogger->expects($this->once())
510511
->method('log')
511512
->with(LogLevel::WARNING, 'Foo message', ['exception' => $exception]);
@@ -520,7 +521,7 @@ public function testSettingLoggerWhenExceptionIsBuffered()
520521

521522
$exception = new \Exception('Foo message');
522523

523-
$mockLogger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
524+
$mockLogger = $this->createMock(LoggerInterface::class);
524525
$mockLogger->expects($this->once())
525526
->method('log')
526527
->with(LogLevel::CRITICAL, 'Uncaught Exception: Foo message', ['exception' => $exception]);
@@ -535,7 +536,7 @@ public function testSettingLoggerWhenExceptionIsBuffered()
535536
public function testHandleFatalError()
536537
{
537538
try {
538-
$logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
539+
$logger = $this->createMock(LoggerInterface::class);
539540
$handler = ErrorHandler::register();
540541

541542
$error = [

0 commit comments

Comments
 (0)