Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/3220' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/Writer/MongoDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use DateTime;
use Mongo;
use MongoClient;
use MongoDate;
use Traversable;
use Zend\Log\Exception;
Expand Down Expand Up @@ -45,7 +46,7 @@ class MongoDB extends AbstractWriter
/**
* Constructor
*
* @param Mongo|array|Traversable $mongo
* @param Mongo|MongoClient|array|Traversable $mongo
* @param string|MongoDB $database
* @param string $collection
* @param array $saveOptions
Expand Down Expand Up @@ -77,9 +78,9 @@ public function __construct($mongo, $database = null, $collection = null, array
);
}

if (!($mongo instanceof Mongo)) {
if (!($mongo instanceof MongoClient || $mongo instanceof Mongo)) {
throw new Exception\InvalidArgumentException(
'Parameter of type %s is invalid; must be Mongo',
'Parameter of type %s is invalid; must be MongoClient or Mongo',
(is_object($mongo) ? get_class($mongo) : gettype($mongo))
);
}
Expand Down
4 changes: 3 additions & 1 deletion test/Writer/MongoDBTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ public function setUp()
$this->database = 'zf2_test';
$this->collection = 'logs';

$this->mongo = $this->getMockBuilder('Mongo')
$mongoClass = (version_compare(phpversion('mongo'), '1.3.0', '<')) ? 'Mongo' : 'MongoClient';

$this->mongo = $this->getMockBuilder($mongoClass)
->disableOriginalConstructor()
->setMethods(array('selectCollection'))
->getMock();
Expand Down

0 comments on commit 1731915

Please sign in to comment.