MonologHandlerMongoDBHandlerTest

The Gravity PDF Monolog Handler MongoDBHandlerTest class.

Defined (1)

The class is defined in the following location(s).

/vendor/monolog/monolog/tests/Monolog/Handler/MongoDBHandlerTest.php  
  1. class MongoDBHandlerTest extends TestCase 
  2. /** 
  3. * @expectedException InvalidArgumentException 
  4. */ 
  5. public function testConstructorShouldThrowExceptionForInvalidMongo() 
  6. new MongoDBHandler(new \stdClass(), 'DB', 'Collection'); 
  7.  
  8. public function testHandle() 
  9. $mongo = $this->getMock('Mongo', array('selectCollection'), array(), '', false); 
  10. $collection = $this->getMock('stdClass', array('save')); 
  11.  
  12. $mongo->expects($this->once()) 
  13. ->method('selectCollection') 
  14. ->with('DB', 'Collection') 
  15. ->will($this->returnValue($collection)); 
  16.  
  17. $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34)); 
  18.  
  19. $expected = array( 
  20. 'message' => 'test',  
  21. 'context' => array('data' => '[object] (stdClass: {})', 'foo' => 34),  
  22. 'level' => Logger::WARNING,  
  23. 'level_name' => 'WARNING',  
  24. 'channel' => 'test',  
  25. 'datetime' => $record['datetime']->format('Y-m-d H:i:s'),  
  26. 'extra' => array(),  
  27. ); 
  28.  
  29. $collection->expects($this->once()) 
  30. ->method('save') 
  31. ->with($expected); 
  32.  
  33. $handler = new MongoDBHandler($mongo, 'DB', 'Collection'); 
  34. $handler->handle($record);