Permalink
Browse files

Merge remote-tracking branch 'origin/master'

  • Loading branch information...
2 parents 5e78992 + b67085d commit 8dd213fcf1aea5fad595e44cffab50a922d06854 @Seldaek committed Dec 14, 2012
Showing with 13 additions and 1 deletion.
  1. +5 −1 src/Monolog/Handler/MongoDBHandler.php
  2. +8 −0 tests/Monolog/Handler/MongoDBHandlerTest.php
View
6 src/Monolog/Handler/MongoDBHandler.php
@@ -29,8 +29,12 @@ class MongoDBHandler extends AbstractProcessingHandler
{
private $mongoCollection;
- public function __construct(\Mongo $mongo, $database, $collection, $level = Logger::DEBUG, $bubble = true)
+ public function __construct($mongo, $database, $collection, $level = Logger::DEBUG, $bubble = true)
{
+ if (!($mongo instanceof \MongoClient || $mongo instanceof \Mongo)) {
+ throw new \InvalidArgumentException('MongoClient or Mongo instance required');
+ }
+
$this->mongoCollection = $mongo->selectCollection($database, $collection);
parent::__construct($level, $bubble);
View
8 tests/Monolog/Handler/MongoDBHandlerTest.php
@@ -16,6 +16,14 @@
class MongoDBHandlerTest extends TestCase
{
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testConstructorShouldThrowExceptionForInvalidMongo()
+ {
+ new MongoDBHandler(new \stdClass(), 'DB', 'Collection');
+ }
+
public function testHandle()
{
$mongo = $this->getMock('Mongo', array('selectCollection'));

0 comments on commit 8dd213f

Please sign in to comment.