ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Monolog\Handler\SyslogUdpHandlerTest Class Reference

@requires extension sockets More...

+ Inheritance diagram for Monolog\Handler\SyslogUdpHandlerTest:
+ Collaboration diagram for Monolog\Handler\SyslogUdpHandlerTest:

Public Member Functions

 testWeValidateFacilities ()
 @expectedException UnexpectedValueException More...
 
 testWeSplitIntoLines ()
 
 testSplitWorksOnEmptyMsg ()
 

Protected Member Functions

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

Detailed Description

@requires extension sockets

Definition at line 19 of file SyslogUdpHandlerTest.php.

Member Function Documentation

◆ getRecordWithMessage()

Monolog\Handler\SyslogUdpHandlerTest::getRecordWithMessage (   $msg)
protected

Definition at line 72 of file SyslogUdpHandlerTest.php.

73 {
74 return array('message' => $msg, 'level' => \Monolog\Logger::WARNING, 'context' => null, 'extra' => array(), 'channel' => 'lol');
75 }
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:53

References Monolog\Logger\WARNING.

Referenced by Monolog\Handler\SyslogUdpHandlerTest\testSplitWorksOnEmptyMsg(), and Monolog\Handler\SyslogUdpHandlerTest\testWeSplitIntoLines().

+ Here is the caller graph for this function:

◆ testSplitWorksOnEmptyMsg()

Monolog\Handler\SyslogUdpHandlerTest::testSplitWorksOnEmptyMsg ( )

Definition at line 58 of file SyslogUdpHandlerTest.php.

59 {
60 $handler = new SyslogUdpHandler("127.0.0.1", 514, "authpriv");
61 $handler->setFormatter($this->getIdentityFormatter());
62
63 $socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('write'), array('lol', 'lol'));
64 $socket->expects($this->never())
65 ->method('write');
66
67 $handler->setSocket($socket);
68
69 $handler->handle($this->getRecordWithMessage(null));
70 }
$handler

References $handler, Monolog\TestCase\getIdentityFormatter(), and Monolog\Handler\SyslogUdpHandlerTest\getRecordWithMessage().

+ Here is the call graph for this function:

◆ testWeSplitIntoLines()

Monolog\Handler\SyslogUdpHandlerTest::testWeSplitIntoLines ( )

Definition at line 29 of file SyslogUdpHandlerTest.php.

30 {
31 $time = '2014-01-07T12:34';
32 $pid = getmypid();
33 $host = gethostname();
34
35 $handler = $this->getMockBuilder('\Monolog\Handler\SyslogUdpHandler')
36 ->setConstructorArgs(array("127.0.0.1", 514, "authpriv"))
37 ->setMethods(array('getDateTime'))
38 ->getMock();
39
40 $handler->method('getDateTime')
41 ->willReturn($time);
42
43 $handler->setFormatter(new \Monolog\Formatter\ChromePHPFormatter());
44
45 $socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('write'), array('lol', 'lol'));
46 $socket->expects($this->at(0))
47 ->method('write')
48 ->with("lol", "<".(LOG_AUTHPRIV + LOG_WARNING).">1 $time $host php $pid - - ");
49 $socket->expects($this->at(1))
50 ->method('write')
51 ->with("hej", "<".(LOG_AUTHPRIV + LOG_WARNING).">1 $time $host php $pid - - ");
52
53 $handler->setSocket($socket);
54
55 $handler->handle($this->getRecordWithMessage("hej\nlol"));
56 }
$time
Definition: cron.php:21

References $handler, $time, and Monolog\Handler\SyslogUdpHandlerTest\getRecordWithMessage().

+ Here is the call graph for this function:

◆ testWeValidateFacilities()

Monolog\Handler\SyslogUdpHandlerTest::testWeValidateFacilities ( )

@expectedException UnexpectedValueException

Definition at line 24 of file SyslogUdpHandlerTest.php.

25 {
26 $handler = new SyslogUdpHandler("ip", null, "invalidFacility");
27 }

References $handler.


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