ILIAS  release_5-2 Revision v5.2.25-18-g3f80b82851
Monolog\Handler\GelfHandlerTest Class Reference
+ Inheritance diagram for Monolog\Handler\GelfHandlerTest:
+ Collaboration diagram for Monolog\Handler\GelfHandlerTest:

Public Member Functions

 setUp ()
 
 testConstruct ()
 Monolog::__construct More...
 
 testDebug ()
 
 testWarning ()
 
 testInjectedGelfMessageFormatter ()
 

Protected Member Functions

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

Detailed Description

Definition at line 19 of file GelfHandlerTest.php.

Member Function Documentation

◆ getHandler()

Monolog\Handler\GelfHandlerTest::getHandler (   $messagePublisher)
protected

Definition at line 37 of file GelfHandlerTest.php.

Referenced by Monolog\Handler\GelfHandlerTest\testDebug(), Monolog\Handler\GelfHandlerTest\testInjectedGelfMessageFormatter(), and Monolog\Handler\GelfHandlerTest\testWarning().

38  {
39  $handler = new GelfHandler($messagePublisher);
40 
41  return $handler;
42  }
+ Here is the caller graph for this function:

◆ getMessagePublisher()

Monolog\Handler\GelfHandlerTest::getMessagePublisher ( )
protected

Definition at line 44 of file GelfHandlerTest.php.

References array.

Referenced by Monolog\Handler\GelfHandlerTest\testConstruct(), Monolog\Handler\GelfHandlerTest\testDebug(), Monolog\Handler\GelfHandlerTest\testInjectedGelfMessageFormatter(), and Monolog\Handler\GelfHandlerTest\testWarning().

45  {
46  return $this->getMock('Gelf\Publisher', array('publish'), array(), '', false);
47  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ setUp()

Monolog\Handler\GelfHandlerTest::setUp ( )

Definition at line 21 of file GelfHandlerTest.php.

22  {
23  if (!class_exists('Gelf\Publisher') || !class_exists('Gelf\Message')) {
24  $this->markTestSkipped("graylog2/gelf-php not installed");
25  }
26  }

◆ testConstruct()

Monolog\Handler\GelfHandlerTest::testConstruct ( )

Monolog::__construct

Definition at line 31 of file GelfHandlerTest.php.

References Monolog\Handler\GelfHandlerTest\getMessagePublisher().

32  {
33  $handler = new GelfHandler($this->getMessagePublisher());
34  $this->assertInstanceOf('Monolog\Handler\GelfHandler', $handler);
35  }
+ Here is the call graph for this function:

◆ testDebug()

Monolog\Handler\GelfHandlerTest::testDebug ( )

Definition at line 49 of file GelfHandlerTest.php.

References Monolog\Logger\DEBUG, Monolog\Handler\GelfHandlerTest\getHandler(), Monolog\Handler\GelfHandlerTest\getMessagePublisher(), and Monolog\TestCase\getRecord().

50  {
51  $record = $this->getRecord(Logger::DEBUG, "A test debug message");
52  $expectedMessage = new Message();
53  $expectedMessage
54  ->setLevel(7)
55  ->setFacility("test")
56  ->setShortMessage($record['message'])
57  ->setTimestamp($record['datetime'])
58  ;
59 
60  $messagePublisher = $this->getMessagePublisher();
61  $messagePublisher->expects($this->once())
62  ->method('publish')
63  ->with($expectedMessage);
64 
65  $handler = $this->getHandler($messagePublisher);
66 
67  $handler->handle($record);
68  }
const DEBUG
Detailed debug information.
Definition: Logger.php:32
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
+ Here is the call graph for this function:

◆ testInjectedGelfMessageFormatter()

Monolog\Handler\GelfHandlerTest::testInjectedGelfMessageFormatter ( )

Definition at line 91 of file GelfHandlerTest.php.

References Monolog\Handler\GelfHandlerTest\getHandler(), Monolog\Handler\GelfHandlerTest\getMessagePublisher(), Monolog\TestCase\getRecord(), and Monolog\Logger\WARNING.

92  {
93  $record = $this->getRecord(Logger::WARNING, "A test warning message");
94  $record['extra']['blarg'] = 'yep';
95  $record['context']['from'] = 'logger';
96 
97  $expectedMessage = new Message();
98  $expectedMessage
99  ->setLevel(4)
100  ->setFacility("test")
101  ->setHost("mysystem")
102  ->setShortMessage($record['message'])
103  ->setTimestamp($record['datetime'])
104  ->setAdditional("EXTblarg", 'yep')
105  ->setAdditional("CTXfrom", 'logger')
106  ;
107 
108  $messagePublisher = $this->getMessagePublisher();
109  $messagePublisher->expects($this->once())
110  ->method('publish')
111  ->with($expectedMessage);
112 
113  $handler = $this->getHandler($messagePublisher);
114  $handler->setFormatter(new GelfMessageFormatter('mysystem', 'EXT', 'CTX'));
115  $handler->handle($record);
116  }
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:52
+ Here is the call graph for this function:

◆ testWarning()

Monolog\Handler\GelfHandlerTest::testWarning ( )

Definition at line 70 of file GelfHandlerTest.php.

References Monolog\Handler\GelfHandlerTest\getHandler(), Monolog\Handler\GelfHandlerTest\getMessagePublisher(), Monolog\TestCase\getRecord(), and Monolog\Logger\WARNING.

71  {
72  $record = $this->getRecord(Logger::WARNING, "A test warning message");
73  $expectedMessage = new Message();
74  $expectedMessage
75  ->setLevel(4)
76  ->setFacility("test")
77  ->setShortMessage($record['message'])
78  ->setTimestamp($record['datetime'])
79  ;
80 
81  $messagePublisher = $this->getMessagePublisher();
82  $messagePublisher->expects($this->once())
83  ->method('publish')
84  ->with($expectedMessage);
85 
86  $handler = $this->getHandler($messagePublisher);
87 
88  $handler->handle($record);
89  }
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:52
+ Here is the call graph for this function:

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