ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Monolog\Handler\GelfHandlerLegacyTest Class Reference
+ Inheritance diagram for Monolog\Handler\GelfHandlerLegacyTest:
+ Collaboration diagram for Monolog\Handler\GelfHandlerLegacyTest:

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 GelfHandlerLegacyTest.php.

Member Function Documentation

◆ getHandler()

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

Definition at line 39 of file GelfHandlerLegacyTest.php.

References $handler.

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

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

◆ getMessagePublisher()

Monolog\Handler\GelfHandlerLegacyTest::getMessagePublisher ( )
protected

Definition at line 46 of file GelfHandlerLegacyTest.php.

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

47  {
48  return new GelfMockMessagePublisher('localhost');
49  }
+ Here is the caller graph for this function:

◆ setUp()

Monolog\Handler\GelfHandlerLegacyTest::setUp ( )

Definition at line 21 of file GelfHandlerLegacyTest.php.

22  {
23  if (!class_exists('Gelf\MessagePublisher') || !class_exists('Gelf\Message')) {
24  $this->markTestSkipped("mlehner/gelf-php not installed");
25  }
26 
27  require_once __DIR__ . '/GelfMockMessagePublisher.php';
28  }

◆ testConstruct()

Monolog\Handler\GelfHandlerLegacyTest::testConstruct ( )

Monolog::__construct

Definition at line 33 of file GelfHandlerLegacyTest.php.

References $handler, and Monolog\Handler\GelfHandlerLegacyTest\getMessagePublisher().

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

◆ testDebug()

Monolog\Handler\GelfHandlerLegacyTest::testDebug ( )

Definition at line 51 of file GelfHandlerLegacyTest.php.

References $handler, Monolog\Logger\DEBUG, Monolog\Handler\GelfHandlerLegacyTest\getHandler(), Monolog\Handler\GelfHandlerLegacyTest\getMessagePublisher(), and Monolog\TestCase\getRecord().

52  {
53  $messagePublisher = $this->getMessagePublisher();
54  $handler = $this->getHandler($messagePublisher);
55 
56  $record = $this->getRecord(Logger::DEBUG, "A test debug message");
57  $handler->handle($record);
58 
59  $this->assertEquals(7, $messagePublisher->lastMessage->getLevel());
60  $this->assertEquals('test', $messagePublisher->lastMessage->getFacility());
61  $this->assertEquals($record['message'], $messagePublisher->lastMessage->getShortMessage());
62  $this->assertEquals(null, $messagePublisher->lastMessage->getFullMessage());
63  }
const DEBUG
Detailed debug information.
Definition: Logger.php:32
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
$handler
+ Here is the call graph for this function:

◆ testInjectedGelfMessageFormatter()

Monolog\Handler\GelfHandlerLegacyTest::testInjectedGelfMessageFormatter ( )

Definition at line 79 of file GelfHandlerLegacyTest.php.

References $handler, Monolog\Handler\GelfHandlerLegacyTest\getHandler(), Monolog\Handler\GelfHandlerLegacyTest\getMessagePublisher(), Monolog\TestCase\getRecord(), and Monolog\Logger\WARNING.

80  {
81  $messagePublisher = $this->getMessagePublisher();
82  $handler = $this->getHandler($messagePublisher);
83 
84  $handler->setFormatter(new GelfMessageFormatter('mysystem', 'EXT', 'CTX'));
85 
86  $record = $this->getRecord(Logger::WARNING, "A test warning message");
87  $record['extra']['blarg'] = 'yep';
88  $record['context']['from'] = 'logger';
89  $handler->handle($record);
90 
91  $this->assertEquals('mysystem', $messagePublisher->lastMessage->getHost());
92  $this->assertArrayHasKey('_EXTblarg', $messagePublisher->lastMessage->toArray());
93  $this->assertArrayHasKey('_CTXfrom', $messagePublisher->lastMessage->toArray());
94  }
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:52
$handler
+ Here is the call graph for this function:

◆ testWarning()

Monolog\Handler\GelfHandlerLegacyTest::testWarning ( )

Definition at line 65 of file GelfHandlerLegacyTest.php.

References $handler, Monolog\Handler\GelfHandlerLegacyTest\getHandler(), Monolog\Handler\GelfHandlerLegacyTest\getMessagePublisher(), Monolog\TestCase\getRecord(), and Monolog\Logger\WARNING.

66  {
67  $messagePublisher = $this->getMessagePublisher();
68  $handler = $this->getHandler($messagePublisher);
69 
70  $record = $this->getRecord(Logger::WARNING, "A test warning message");
71  $handler->handle($record);
72 
73  $this->assertEquals(4, $messagePublisher->lastMessage->getLevel());
74  $this->assertEquals('test', $messagePublisher->lastMessage->getFacility());
75  $this->assertEquals($record['message'], $messagePublisher->lastMessage->getShortMessage());
76  $this->assertEquals(null, $messagePublisher->lastMessage->getFullMessage());
77  }
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:52
$handler
+ Here is the call graph for this function:

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