Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f3bb644

Browse files
Merge 4.8 into 5.0 (#3116)
2 parents fbed3dc + f24b464 commit f3bb644

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

‎src/Connection.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,12 @@ public function getDriverName()
294294
return 'mongodb';
295295
}
296296

297+
/** @inheritdoc */
298+
public function getDriverTitle()
299+
{
300+
return 'MongoDB';
301+
}
302+
297303
/** @inheritdoc */
298304
protected function getDefaultPostProcessor()
299305
{
@@ -320,6 +326,14 @@ public function setDatabase(Database $db)
320326
$this->db = $db;
321327
}
322328

329+
/** @inheritdoc */
330+
public function threadCount()
331+
{
332+
$status = $this->db->command(['serverStatus' => 1])->toArray();
333+
334+
return $status[0]['connections']['current'];
335+
}
336+
323337
/**
324338
* Dynamically pass methods to the connection.
325339
*

‎tests/ConnectionTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ public function testConnection()
2525
{
2626
$connection = DB::connection('mongodb');
2727
$this->assertInstanceOf(Connection::class, $connection);
28+
29+
$this->assertSame('mongodb', $connection->getDriverName());
30+
$this->assertSame('MongoDB', $connection->getDriverTitle());
2831
}
2932

3033
public function testReconnect()
@@ -305,4 +308,12 @@ public function testServerVersion()
305308
$version = DB::connection('mongodb')->getServerVersion();
306309
$this->assertIsString($version);
307310
}
311+
312+
public function testThreadsCount()
313+
{
314+
$threads = DB::connection('mongodb')->threadCount();
315+
316+
$this->assertIsInt($threads);
317+
$this->assertGreaterThanOrEqual(1, $threads);
318+
}
308319
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /