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
This commit is contained in:
commit
e62d98ef30
@ -34,6 +34,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$mongoClass = version_compare(phpversion('mongo'), '1.3.0', '<') ? 'Mongo' : 'MongoClient';
|
$mongoClass = version_compare(phpversion('mongo'), '1.3.0', '<') ? 'Mongo' : 'MongoClient';
|
||||||
|
|
||||||
$this->mongo = $this->getMockBuilder($mongoClass)
|
$this->mongo = $this->getMockBuilder($mongoClass)
|
||||||
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$this->options = array(
|
$this->options = array(
|
||||||
@ -202,13 +203,8 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
private function createMongoCollectionMock()
|
private function createMongoCollectionMock()
|
||||||
{
|
{
|
||||||
$mongoClient = $this->getMockBuilder('MongoClient')
|
|
||||||
->getMock();
|
|
||||||
$mongoDb = $this->getMockBuilder('MongoDB')
|
|
||||||
->setConstructorArgs(array($mongoClient, 'database-name'))
|
|
||||||
->getMock();
|
|
||||||
$collection = $this->getMockBuilder('MongoCollection')
|
$collection = $this->getMockBuilder('MongoCollection')
|
||||||
->setConstructorArgs(array($mongoDb, 'collection-name'))
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
return $collection;
|
return $collection;
|
||||||
|
Reference in New Issue
Block a user