Skip to content
This repository has been archived by the owner on Nov 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #195
Browse files Browse the repository at this point in the history
  • Loading branch information
jmikola committed Dec 8, 2014
2 parents 006f186 + 7cc3ad0 commit ffb7cf5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"require": {
"php": ">=5.3.2",
"ext-mongo": ">=1.2.12,<1.6-dev",
"ext-mongo": ">=1.2.12,<1.7-dev",
"doctrine/common": ">=2.1.0,<2.5-dev"
},
"autoload": {
Expand Down
7 changes: 6 additions & 1 deletion lib/Doctrine/MongoDB/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,12 @@ public function isConnected()
return false;
}

return $this->mongo->connected;
/* MongoClient::$connected is deprecated in 1.5.0+, so count the list of
* connected hosts instead.
*/
return version_compare(phpversion('mongo'), '1.5.0', '<')
? $this->mongo->connected
: count($this->mongo->getHosts()) > 0;
}

/**
Expand Down
15 changes: 15 additions & 0 deletions tests/Doctrine/MongoDB/Tests/ConnectionFunctionalTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Doctrine\MongoDB\Tests;

class ConnectionFunctionalTest extends BaseTest
{
public function testIsConnected()
{
$this->assertFalse($this->conn->isConnected());
$this->conn->connect();
$this->assertTrue($this->conn->isConnected());
$this->conn->close();
$this->assertFalse($this->conn->isConnected());
}
}

0 comments on commit ffb7cf5

Please sign in to comment.