ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
Monolog\Formatter\JsonFormatterTest Class Reference
+ Inheritance diagram for Monolog\Formatter\JsonFormatterTest:
+ Collaboration diagram for Monolog\Formatter\JsonFormatterTest:

Public Member Functions

 testConstruct ()
 Monolog::__construct Monolog::getBatchMode Monolog::isAppendingNewlines More...
 
 testFormat ()
 Monolog::format More...
 
 testFormatBatch ()
 Monolog::formatBatch Monolog::formatBatchJson More...
 
 testFormatBatchNewlines ()
 Monolog::formatBatch Monolog::formatBatchNewlines More...
 

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

Member Function Documentation

◆ testConstruct()

Monolog\Formatter\JsonFormatterTest::testConstruct ( )

Monolog::__construct Monolog::getBatchMode Monolog::isAppendingNewlines

Definition at line 24 of file JsonFormatterTest.php.

References Monolog\Formatter\JsonFormatter\BATCH_MODE_JSON, and Monolog\Formatter\JsonFormatter\BATCH_MODE_NEWLINES.

25  {
26  $formatter = new JsonFormatter();
27  $this->assertEquals(JsonFormatter::BATCH_MODE_JSON, $formatter->getBatchMode());
28  $this->assertEquals(true, $formatter->isAppendingNewlines());
29  $formatter = new JsonFormatter(JsonFormatter::BATCH_MODE_NEWLINES, false);
30  $this->assertEquals(JsonFormatter::BATCH_MODE_NEWLINES, $formatter->getBatchMode());
31  $this->assertEquals(false, $formatter->isAppendingNewlines());
32  }

◆ testFormat()

Monolog\Formatter\JsonFormatterTest::testFormat ( )

Monolog::format

Definition at line 37 of file JsonFormatterTest.php.

References Monolog\Formatter\JsonFormatter\BATCH_MODE_JSON, and Monolog\TestCase\getRecord().

38  {
39  $formatter = new JsonFormatter();
40  $record = $this->getRecord();
41  $this->assertEquals(json_encode($record)."\n", $formatter->format($record));
42 
43  $formatter = new JsonFormatter(JsonFormatter::BATCH_MODE_JSON, false);
44  $record = $this->getRecord();
45  $this->assertEquals(json_encode($record), $formatter->format($record));
46  }
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
+ Here is the call graph for this function:

◆ testFormatBatch()

Monolog\Formatter\JsonFormatterTest::testFormatBatch ( )

Monolog::formatBatch Monolog::formatBatchJson

Definition at line 52 of file JsonFormatterTest.php.

References $records, Monolog\Logger\DEBUG, Monolog\TestCase\getRecord(), and Monolog\Logger\WARNING.

53  {
54  $formatter = new JsonFormatter();
55  $records = array(
56  $this->getRecord(Logger::WARNING),
57  $this->getRecord(Logger::DEBUG),
58  );
59  $this->assertEquals(json_encode($records), $formatter->formatBatch($records));
60  }
const DEBUG
Detailed debug information.
Definition: Logger.php:32
$records
Definition: simple_test.php:17
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:

◆ testFormatBatchNewlines()

Monolog\Formatter\JsonFormatterTest::testFormatBatchNewlines ( )

Monolog::formatBatch Monolog::formatBatchNewlines

Definition at line 66 of file JsonFormatterTest.php.

References $records, Monolog\Formatter\JsonFormatter\BATCH_MODE_NEWLINES, Monolog\Logger\DEBUG, Monolog\TestCase\getRecord(), and Monolog\Logger\WARNING.

67  {
68  $formatter = new JsonFormatter(JsonFormatter::BATCH_MODE_NEWLINES);
69  $records = $expected = array(
70  $this->getRecord(Logger::WARNING),
71  $this->getRecord(Logger::DEBUG),
72  );
73  array_walk($expected, function (&$value, $key) {
74  $value = json_encode($value);
75  });
76  $this->assertEquals(implode("\n", $expected), $formatter->formatBatch($records));
77  }
const DEBUG
Detailed debug information.
Definition: Logger.php:32
$records
Definition: simple_test.php:17
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: