diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php index e8293e4dde..2315bf8f58 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php @@ -137,7 +137,7 @@ class MongoDbSessionHandler implements \SessionHandlerInterface private function getCollection() { if (null === $this->collection) { - $this->collection = $this->mongo->selectDB($this->options['database'])->selectCollection($this->options['collection']); + $this->collection = $this->mongo->selectCollection($this->options['database'], $this->options['collection']); } return $this->collection; diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php index d2232f1814..f7e51d87e1 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php @@ -58,22 +58,13 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase public function testWrite() { - $database = $this->getMockBuilder('MongoDB') - ->disableOriginalConstructor() - ->getMock(); - $collection = $this->getMockBuilder('MongoCollection') ->disableOriginalConstructor() ->getMock(); $this->mongo->expects($this->once()) - ->method('selectDB') - ->with($this->options['database']) - ->will($this->returnValue($database)); - - $database->expects($this->once()) ->method('selectCollection') - ->with($this->options['collection']) + ->with($this->options['database'], $this->options['collection']) ->will($this->returnValue($collection)); $that = $this; @@ -96,22 +87,13 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase public function testReplaceSessionData() { - $database = $this->getMockBuilder('MongoDB') - ->disableOriginalConstructor() - ->getMock(); - $collection = $this->getMockBuilder('MongoCollection') ->disableOriginalConstructor() ->getMock(); $this->mongo->expects($this->once()) - ->method('selectDB') - ->with($this->options['database']) - ->will($this->returnValue($database)); - - $database->expects($this->once()) ->method('selectCollection') - ->with($this->options['collection']) + ->with($this->options['database'], $this->options['collection']) ->will($this->returnValue($collection)); $data = array(); @@ -130,22 +112,13 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase public function testDestroy() { - $database = $this->getMockBuilder('MongoDB') - ->disableOriginalConstructor() - ->getMock(); - $collection = $this->getMockBuilder('MongoCollection') ->disableOriginalConstructor() ->getMock(); $this->mongo->expects($this->once()) - ->method('selectDB') - ->with($this->options['database']) - ->will($this->returnValue($database)); - - $database->expects($this->once()) ->method('selectCollection') - ->with($this->options['collection']) + ->with($this->options['database'], $this->options['collection']) ->will($this->returnValue($collection)); $collection->expects($this->once()) @@ -160,22 +133,13 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase public function testGc() { - $database = $this->getMockBuilder('MongoDB') - ->disableOriginalConstructor() - ->getMock(); - $collection = $this->getMockBuilder('MongoCollection') ->disableOriginalConstructor() ->getMock(); $this->mongo->expects($this->once()) - ->method('selectDB') - ->with($this->options['database']) - ->will($this->returnValue($database)); - - $database->expects($this->once()) ->method('selectCollection') - ->with($this->options['collection']) + ->with($this->options['database'], $this->options['collection']) ->will($this->returnValue($collection)); $that = $this;