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

Public Member Functions

 testWriteContent ()
 
 testWriteBatchContent ()
 

Private Member Functions

 createHandler ()
 

Private Attributes

 $res
 
 $handler
 

Additional Inherited Members

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

Detailed Description

Author
Robert Kaufmann III rok3@.nosp@m.rok3.nosp@m..me

Definition at line 20 of file LogEntriesHandlerTest.php.

Member Function Documentation

◆ createHandler()

Monolog\Handler\LogEntriesHandlerTest::createHandler ( )
private

Definition at line 59 of file LogEntriesHandlerTest.php.

References array, and Monolog\Logger\DEBUG.

Referenced by Monolog\Handler\LogEntriesHandlerTest\testWriteBatchContent(), and Monolog\Handler\LogEntriesHandlerTest\testWriteContent().

60  {
61  $useSSL = extension_loaded('openssl');
62  $args = array('testToken', $useSSL, Logger::DEBUG, true);
63  $this->res = fopen('php://memory', 'a');
64  $this->handler = $this->getMock(
65  '\Monolog\Handler\LogEntriesHandler',
66  array('fsockopen', 'streamSetTimeout', 'closeSocket'),
67  $args
68  );
69 
70  $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString');
71  $reflectionProperty->setAccessible(true);
72  $reflectionProperty->setValue($this->handler, 'localhost:1234');
73 
74  $this->handler->expects($this->any())
75  ->method('fsockopen')
76  ->will($this->returnValue($this->res));
77  $this->handler->expects($this->any())
78  ->method('streamSetTimeout')
79  ->will($this->returnValue(true));
80  $this->handler->expects($this->any())
81  ->method('closeSocket')
82  ->will($this->returnValue(true));
83  }
const DEBUG
Detailed debug information.
Definition: Logger.php:32
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ testWriteBatchContent()

Monolog\Handler\LogEntriesHandlerTest::testWriteBatchContent ( )

Definition at line 43 of file LogEntriesHandlerTest.php.

References $records, array, Monolog\Handler\LogEntriesHandlerTest\createHandler(), and Monolog\TestCase\getRecord().

44  {
45  $records = array(
46  $this->getRecord(),
47  $this->getRecord(),
48  $this->getRecord(),
49  );
50  $this->createHandler();
51  $this->handler->handleBatch($records);
52 
53  fseek($this->res, 0);
54  $content = fread($this->res, 1024);
55 
56  $this->assertRegexp('/(testToken \[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\] .* \[\] \[\]\n){3}/', $content);
57  }
$records
Definition: simple_test.php:22
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ testWriteContent()

Monolog\Handler\LogEntriesHandlerTest::testWriteContent ( )

Definition at line 32 of file LogEntriesHandlerTest.php.

References Monolog\Handler\LogEntriesHandlerTest\createHandler(), Monolog\Logger\CRITICAL, and Monolog\TestCase\getRecord().

33  {
34  $this->createHandler();
35  $this->handler->handle($this->getRecord(Logger::CRITICAL, 'Critical write test'));
36 
37  fseek($this->res, 0);
38  $content = fread($this->res, 1024);
39 
40  $this->assertRegexp('/testToken \[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\] test.CRITICAL: Critical write test/', $content);
41  }
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
const CRITICAL
Critical conditions.
Definition: Logger.php:64
+ Here is the call graph for this function:

Field Documentation

◆ $handler

Monolog\Handler\LogEntriesHandlerTest::$handler
private

Definition at line 30 of file LogEntriesHandlerTest.php.

◆ $res

Monolog\Handler\LogEntriesHandlerTest::$res
private

Definition at line 25 of file LogEntriesHandlerTest.php.


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