Skip to content

Commit ac1cca1

Browse files
committed
Update class refs for MongoDB extension and library
1 parent a878712 commit ac1cca1

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

src/Monolog/Handler/MongoDBHandler.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111

1212
namespace Monolog\Handler;
1313

14+
use MongoDB\Client;
15+
use MongoDB\Collection;
1416
use MongoDB\Driver\BulkWrite;
1517
use MongoDB\Driver\Manager;
16-
use MongoDB\Client;
1718
use Monolog\Level;
1819
use Monolog\Formatter\FormatterInterface;
1920
use Monolog\Formatter\MongoDBFormatter;
@@ -34,7 +35,7 @@
3435
*/
3536
class MongoDBHandler extends AbstractProcessingHandler
3637
{
37-
private \MongoDB\Collection $collection;
38+
private Collection $collection;
3839

3940
private Client|Manager $manager;
4041

tests/Monolog/Formatter/MongoDBFormatterTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class MongoDBFormatterTest extends \Monolog\Test\MonologTestCase
2424
{
2525
public function setUp(): void
2626
{
27-
if (!class_exists('MongoDB\BSON\UTCDateTime')) {
27+
if (!class_exists(UTCDateTime::class)) {
2828
$this->markTestSkipped('ext-mongodb not installed');
2929
}
3030
}
@@ -67,7 +67,7 @@ public function testSimpleFormat()
6767
$this->assertEquals(Level::Warning->value, $formattedRecord['level']);
6868
$this->assertEquals(Level::Warning->getName(), $formattedRecord['level_name']);
6969
$this->assertEquals('test', $formattedRecord['channel']);
70-
$this->assertInstanceOf('MongoDB\BSON\UTCDateTime', $formattedRecord['datetime']);
70+
$this->assertInstanceOf(UTCDateTime::class, $formattedRecord['datetime']);
7171
$this->assertEquals('1453410690123', $formattedRecord['datetime']->__toString());
7272
$this->assertEquals([], $formattedRecord['extra']);
7373
}
@@ -96,7 +96,7 @@ public function testRecursiveFormat()
9696
$formattedRecord = $formatter->format($record);
9797

9898
$this->assertCount(5, $formattedRecord['context']);
99-
$this->assertInstanceOf('MongoDB\BSON\UTCDateTime', $formattedRecord['context']['stuff']);
99+
$this->assertInstanceOf(UTCDateTime::class, $formattedRecord['context']['stuff']);
100100
$this->assertEquals('-29731710213', $formattedRecord['context']['stuff']->__toString());
101101
$this->assertEquals(
102102
[

tests/Monolog/Handler/MongoDBHandlerTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Monolog\Handler;
1313

14+
use MongoDB\Client;
15+
use MongoDB\Collection;
1416
use MongoDB\Driver\Manager;
1517

1618
/**
@@ -27,15 +29,15 @@ public function testConstructorShouldThrowExceptionForInvalidMongo()
2729

2830
public function testHandleWithLibraryClient()
2931
{
30-
if (!(class_exists('MongoDB\Client'))) {
32+
if (!class_exists(Client::class)) {
3133
$this->markTestSkipped('mongodb/mongodb not installed');
3234
}
3335

34-
$mongodb = $this->getMockBuilder('MongoDB\Client')
36+
$mongodb = $this->getMockBuilder(Client::class)
3537
->disableOriginalConstructor()
3638
->getMock();
3739

38-
$collection = $this->getMockBuilder('MongoDB\Collection')
40+
$collection = $this->getMockBuilder(Collection::class)
3941
->disableOriginalConstructor()
4042
->getMock();
4143

0 commit comments

Comments
 (0)