From 6541b8b72610d5838b2f9ed02592071f49382f28 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 28 Oct 2015 22:19:48 +0100 Subject: [PATCH] don't call constructors on Mongo mock objects Calling the parent constructor of the mocked `Mongo` class tries to connect to a local MongoDB server which fails in case no local server was configured. Similarly, when the parent constructor of the mocked `MongoCollection` class is called it performs checks on the passed arguments which fails again when a connection was not established successfully before. --- .../Session/Storage/Handler/MongoDbSessionHandlerTest.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) 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 c72358afc8..755be2fcf3 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php @@ -34,6 +34,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase $mongoClass = version_compare(phpversion('mongo'), '1.3.0', '<') ? 'Mongo' : 'MongoClient'; $this->mongo = $this->getMockBuilder($mongoClass) + ->disableOriginalConstructor() ->getMock(); $this->options = array( @@ -202,13 +203,8 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase private function createMongoCollectionMock() { - $mongoClient = $this->getMockBuilder('MongoClient') - ->getMock(); - $mongoDb = $this->getMockBuilder('MongoDB') - ->setConstructorArgs(array($mongoClient, 'database-name')) - ->getMock(); $collection = $this->getMockBuilder('MongoCollection') - ->setConstructorArgs(array($mongoDb, 'collection-name')) + ->disableOriginalConstructor() ->getMock(); return $collection;