Mongolid\Manager::getConnection PHP Method

getConnection() public method

Get the raw MongoDB connection.
public getConnection ( ) : MongoDB\Client
return MongoDB\Client
    public function getConnection()
    {
        $this->init();
        return $this->connectionPool->getConnection()->getRawConnection();
    }

Usage Example

Example #1
0
 public function testShouldAddAndGetConnection()
 {
     // Arrange
     $manager = new Manager();
     $connection = m::mock(Connection::class);
     $rawConnection = m::mock(Client::class);
     // Act
     $connection->shouldReceive('getRawConnection')->andReturn($rawConnection);
     // Assert
     $manager->addConnection($connection);
     $this->assertEquals($rawConnection, $manager->getConnection());
 }