8000 minor #16370 [HttpFoundation] don't call constructors on Mongo mock o… · symfony/symfony@e62d98e · GitHub
[go: up one dir, main page]

Skip to content

Commit e62d98e

Browse files
committed
minor #16370 [HttpFoundation] don't call constructors on Mongo mock objects (xabbuh)
This PR was merged into the 2.3 branch. Discussion ---------- [HttpFoundation] don't call constructors on Mongo mock objects | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #16287 | License | MIT | Doc PR | 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. Commits ------- 6541b8b don't call constructors on Mongo mock objects
2 parents 87c08d5 + 6541b8b commit e62d98e

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ protected function setUp()
3434
$mongoClass = version_compare(phpversion('mongo'), '1.3.0', '<') ? 'Mongo' : 'MongoClient';
3535

3636
$this->mongo = $this->getMockBuilder($mongoClass)
37+
->disableOriginalConstructor()
3738
->getMock();
3839

3940
$this->options = array(
@@ -202,13 +203,8 @@ public function testGc()
202203

203204
private function createMongoCollectionMock()
204205
{
205-
$mongoClient = $this->getMockBuilder('MongoClient')
206-
->getMock();
207-
$mongoDb = $this->getMockBuilder('MongoDB')
208-
->setConstructorArgs(array($mongoClient, 'database-name'))
209-
->getMock();
210206
$collection = $this->getMockBuilder('MongoCollection')
211-
->setConstructorArgs(array($mongoDb, 'collection-name'))
207+
->disableOriginalConstructor()
212208
->getMock();
213209

214210
return $collection;

0 commit comments

Comments
 (0)
0