ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Monolog\Handler\MongoDBHandlerTest Class Reference
+ Inheritance diagram for Monolog\Handler\MongoDBHandlerTest:
+ Collaboration diagram for Monolog\Handler\MongoDBHandlerTest:

Public Member Functions

 testConstructorShouldThrowExceptionForInvalidMongo ()
 InvalidArgumentException More...
 
 testHandle ()
 

Additional Inherited Members

- Protected Member Functions inherited from Monolog\TestCase
 getRecord ($level=Logger::WARNING, $message='test', $context=array())
 
 getMultipleRecords ()
 
 getIdentityFormatter ()
 

Detailed Description

Definition at line 17 of file MongoDBHandlerTest.php.

Member Function Documentation

◆ testConstructorShouldThrowExceptionForInvalidMongo()

Monolog\Handler\MongoDBHandlerTest::testConstructorShouldThrowExceptionForInvalidMongo ( )

InvalidArgumentException

Definition at line 22 of file MongoDBHandlerTest.php.

23  {
24  new MongoDBHandler(new \stdClass(), 'DB', 'Collection');
25  }

◆ testHandle()

Monolog\Handler\MongoDBHandlerTest::testHandle ( )

Definition at line 27 of file MongoDBHandlerTest.php.

References $handler, Monolog\TestCase\getRecord(), Sabre\Event\once(), and Monolog\Logger\WARNING.

28  {
29  $mongo = $this->getMock('Mongo', array('selectCollection'), array(), '', false);
30  $collection = $this->getMock('stdClass', array('save'));
31 
32  $mongo->expects($this->once())
33  ->method('selectCollection')
34  ->with('DB', 'Collection')
35  ->will($this->returnValue($collection));
36 
37  $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
38 
39  $expected = array(
40  'message' => 'test',
41  'context' => array('data' => '[object] (stdClass: {})', 'foo' => 34),
42  'level' => Logger::WARNING,
43  'level_name' => 'WARNING',
44  'channel' => 'test',
45  'datetime' => $record['datetime']->format('Y-m-d H:i:s'),
46  'extra' => array(),
47  );
48 
49  $collection->expects($this->once())
50  ->method('save')
51  ->with($expected);
52 
53  $handler = new MongoDBHandler($mongo, 'DB', 'Collection');
54  $handler->handle($record);
55  }
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:53
$handler
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: