Skip to content
This repository
Browse code

Merge remote-tracking branch 'origin/master'

  • Loading branch information...
commit 8dd213fcf1aea5fad595e44cffab50a922d06854 2 parents 5e78992 + b67085d
Jordi Boggiano authored
6 src/Monolog/Handler/MongoDBHandler.php
@@ -29,8 +29,12 @@ class MongoDBHandler extends AbstractProcessingHandler
29 29 {
30 30 private $mongoCollection;
31 31
32   - public function __construct(\Mongo $mongo, $database, $collection, $level = Logger::DEBUG, $bubble = true)
  32 + public function __construct($mongo, $database, $collection, $level = Logger::DEBUG, $bubble = true)
33 33 {
  34 + if (!($mongo instanceof \MongoClient || $mongo instanceof \Mongo)) {
  35 + throw new \InvalidArgumentException('MongoClient or Mongo instance required');
  36 + }
  37 +
34 38 $this->mongoCollection = $mongo->selectCollection($database, $collection);
35 39
36 40 parent::__construct($level, $bubble);
8 tests/Monolog/Handler/MongoDBHandlerTest.php
@@ -16,6 +16,14 @@
16 16
17 17 class MongoDBHandlerTest extends TestCase
18 18 {
  19 + /**
  20 + * @expectedException InvalidArgumentException
  21 + */
  22 + public function testConstructorShouldThrowExceptionForInvalidMongo()
  23 + {
  24 + new MongoDBHandler(new \stdClass(), 'DB', 'Collection');
  25 + }
  26 +
19 27 public function testHandle()
20 28 {
21 29 $mongo = $this->getMock('Mongo', array('selectCollection'));

0 comments on commit 8dd213f

Please sign in to comment.
Something went wrong with that request. Please try again.