Permalink
Browse files

MongoDB Driver 1.3.0 changes.

As of 1.3.0 the Mongo class is now deprecated which means that the
Connection class have gotten it's typehinting changed. The methods are
still called getMongo and setMongo. This changed have been reflected in
it's Tests.

composer.json now specifies the requirement for ext-mongo to be greater
or equals to 1.3.0.
  • Loading branch information...
1 parent 5b08a48 commit fc956c7c2dd1a7d2742632b436bce91df5454086 @henrikbjorn henrikbjorn committed with jmikola Nov 28, 2012
Showing with 12 additions and 12 deletions.
  1. +1 −1 composer.json
  2. +9 −9 lib/Doctrine/MongoDB/Connection.php
  3. +2 −2 tests/Doctrine/MongoDB/Tests/ConnectionTest.php
View
@@ -12,7 +12,7 @@
],
"require": {
"php": ">=5.3.2",
- "ext-mongo": ">=1.2.12,<1.3-dev",
+ "ext-mongo": ">=1.3.0",
"symfony/yaml": ">=2.0,<2.3-dev",
"symfony/console": ">=2.0,<2.3-dev",
"doctrine/common": ">=2.1.0,<2.5-dev"
@@ -23,7 +23,7 @@
Doctrine\MongoDB\Event\EventArgs;
/**
- * Wrapper for the PHP Mongo class.
+ * Wrapper for the PHP MongoClient class.
*
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link www.doctrine-project.org
@@ -33,7 +33,7 @@
class Connection
{
/**
- * @var Mongo $mongo
+ * @var MongoClient $mongo
*/
protected $mongo;
@@ -67,14 +67,14 @@ class Connection
protected $cmd;
/**
- * Create a new Mongo wrapper instance.
+ * Create a new MongoClient wrapper instance.
*
* @param mixed $server A string server name, an existing Mongo instance or can be omitted.
* @param array $options
*/
public function __construct($server = null, array $options = array(), Configuration $config = null, EventManager $evm = null)
{
- if ($server instanceof \Mongo) {
+ if ($server instanceof \MongoClient) {
$this->mongo = $server;
} elseif ($server !== null) {
$this->server = $server;
@@ -95,7 +95,7 @@ public function initialize($reinitialize = false)
$server = $this->server;
$options = $this->options;
$this->mongo = $this->retry(function() use($server, $options) {
- return new \Mongo($server ?: 'mongodb://localhost:27017', $options);
+ return new \MongoClient($server ?: 'mongodb://localhost:27017', $options);
});
if ($this->eventManager->hasListeners(Events::postConnect)) {
@@ -145,19 +145,19 @@ public function log(array $log)
}
/**
- * Set the PHP Mongo instance to wrap.
+ * Set the PHP MongoClient instance to wrap.
*
- * @param Mongo $mongo The PHP Mongo instance
+ * @param MongoCient $mongo The PHP Mongo instance
*/
- public function setMongo(\Mongo $mongo)
+ public function setMongo(\MongoClient $mongo)
{
$this->mongo = $mongo;
}
/**
* Returns the PHP Mongo instance being wrapped.
*
- * @return Mongo
+ * @return MongoClient
*/
public function getMongo()
{
@@ -13,7 +13,7 @@ public function testInitialize()
$conn = new Connection();
$this->assertNull($conn->getMongo());
$conn->initialize();
- $this->assertInstanceOf('Mongo', $conn->getMongo());
+ $this->assertInstanceOf('MongoClient', $conn->getMongo());
}
public function testLog()
@@ -138,4 +138,4 @@ private function getMockMongoCollection()
{
return $this->getMock('MongoCollection', array(), array(), '', false, false);
}
-}
+}

0 comments on commit fc956c7

Please sign in to comment.