ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
Monolog\Formatter\MongoDBFormatterTest Class Reference
+ Inheritance diagram for Monolog\Formatter\MongoDBFormatterTest:
+ Collaboration diagram for Monolog\Formatter\MongoDBFormatterTest:

Public Member Functions

 setUp ()
 
 constructArgumentProvider ()
 
 testConstruct ($traceDepth, $traceAsString, $expectedTraceDepth, $expectedTraceAsString)
 
 testSimpleFormat ()
 
 testRecursiveFormat ()
 
 testFormatDepthArray ()
 
 testFormatDepthArrayInfiniteNesting ()
 
 testFormatDepthObjects ()
 
 testFormatDepthException ()
 

Detailed Description

Author
Florian Plattner me@fl.nosp@m.oria.nosp@m.nplat.nosp@m.tner.nosp@m..de

Definition at line 19 of file MongoDBFormatterTest.php.

Member Function Documentation

◆ constructArgumentProvider()

Monolog\Formatter\MongoDBFormatterTest::constructArgumentProvider ( )

Definition at line 28 of file MongoDBFormatterTest.php.

References array.

29  {
30  return array(
31  array(1, true, 1, true),
32  array(0, false, 0, false),
33  );
34  }
Create styles array
The data for the language used.

◆ setUp()

Monolog\Formatter\MongoDBFormatterTest::setUp ( )

Definition at line 21 of file MongoDBFormatterTest.php.

22  {
23  if (!class_exists('MongoDate')) {
24  $this->markTestSkipped('mongo extension not installed');
25  }
26  }

◆ testConstruct()

Monolog\Formatter\MongoDBFormatterTest::testConstruct (   $traceDepth,
  $traceAsString,
  $expectedTraceDepth,
  $expectedTraceAsString 
)
Parameters
$traceDepth
$traceAsString
$expectedTraceDepth
$expectedTraceAsStringconstructArgumentProvider

Definition at line 44 of file MongoDBFormatterTest.php.

45  {
46  $formatter = new MongoDBFormatter($traceDepth, $traceAsString);
47 
48  $reflTrace = new \ReflectionProperty($formatter, 'exceptionTraceAsString');
49  $reflTrace->setAccessible(true);
50  $this->assertEquals($expectedTraceAsString, $reflTrace->getValue($formatter));
51 
52  $reflDepth = new\ReflectionProperty($formatter, 'maxNestingLevel');
53  $reflDepth->setAccessible(true);
54  $this->assertEquals($expectedTraceDepth, $reflDepth->getValue($formatter));
55  }

◆ testFormatDepthArray()

Monolog\Formatter\MongoDBFormatterTest::testFormatDepthArray ( )

Definition at line 131 of file MongoDBFormatterTest.php.

References array, Monolog\Logger\getLevelName(), and Monolog\Logger\WARNING.

132  {
133  $record = array(
134  'message' => 'some log message',
135  'context' => array(
136  'nest2' => array(
137  'property' => 'anything',
138  'nest3' => array(
139  'nest4' => 'value',
140  'property' => 'nothing',
141  ),
142  ),
143  ),
144  'level' => Logger::WARNING,
145  'level_name' => Logger::getLevelName(Logger::WARNING),
146  'channel' => 'test',
147  'datetime' => new \DateTime('2014-02-01 00:00:00'),
148  'extra' => array(),
149  );
150 
151  $formatter = new MongoDBFormatter(2);
152  $formattedResult = $formatter->format($record);
153 
154  $this->assertEquals(
155  array(
156  'nest2' => array(
157  'property' => 'anything',
158  'nest3' => '[...]',
159  ),
160  ),
161  $formattedResult['context']
162  );
163  }
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:52
Create styles array
The data for the language used.
static getLevelName($level)
Gets the name of the logging level.
Definition: Logger.php:458
+ Here is the call graph for this function:

◆ testFormatDepthArrayInfiniteNesting()

Monolog\Formatter\MongoDBFormatterTest::testFormatDepthArrayInfiniteNesting ( )

Definition at line 165 of file MongoDBFormatterTest.php.

References array, Monolog\Logger\getLevelName(), and Monolog\Logger\WARNING.

166  {
167  $record = array(
168  'message' => 'some log message',
169  'context' => array(
170  'nest2' => array(
171  'property' => 'something',
172  'nest3' => array(
173  'property' => 'anything',
174  'nest4' => array(
175  'property' => 'nothing',
176  ),
177  ),
178  ),
179  ),
180  'level' => Logger::WARNING,
181  'level_name' => Logger::getLevelName(Logger::WARNING),
182  'channel' => 'test',
183  'datetime' => new \DateTime('2014-02-01 00:00:00'),
184  'extra' => array(),
185  );
186 
187  $formatter = new MongoDBFormatter(0);
188  $formattedResult = $formatter->format($record);
189 
190  $this->assertEquals(
191  array(
192  'nest2' => array(
193  'property' => 'something',
194  'nest3' => array(
195  'property' => 'anything',
196  'nest4' => array(
197  'property' => 'nothing',
198  ),
199  ),
200  ),
201  ),
202  $formattedResult['context']
203  );
204  }
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:52
Create styles array
The data for the language used.
static getLevelName($level)
Gets the name of the logging level.
Definition: Logger.php:458
+ Here is the call graph for this function:

◆ testFormatDepthException()

Monolog\Formatter\MongoDBFormatterTest::testFormatDepthException ( )

Definition at line 241 of file MongoDBFormatterTest.php.

References array, Monolog\Logger\getLevelName(), and Monolog\Logger\WARNING.

242  {
243  $record = array(
244  'message' => 'some log message',
245  'context' => array(
246  'nest2' => new \Exception('exception message', 987),
247  ),
248  'level' => Logger::WARNING,
249  'level_name' => Logger::getLevelName(Logger::WARNING),
250  'channel' => 'test',
251  'datetime' => new \DateTime('2014-02-01 00:00:00'),
252  'extra' => array(),
253  );
254 
255  $formatter = new MongoDBFormatter(2, false);
256  $formattedRecord = $formatter->format($record);
257 
258  $this->assertEquals('exception message', $formattedRecord['context']['nest2']['message']);
259  $this->assertEquals(987, $formattedRecord['context']['nest2']['code']);
260  $this->assertEquals('[...]', $formattedRecord['context']['nest2']['trace']);
261  }
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:52
Create styles array
The data for the language used.
static getLevelName($level)
Gets the name of the logging level.
Definition: Logger.php:458
+ Here is the call graph for this function:

◆ testFormatDepthObjects()

Monolog\Formatter\MongoDBFormatterTest::testFormatDepthObjects ( )

Definition at line 206 of file MongoDBFormatterTest.php.

References array, Monolog\Logger\getLevelName(), and Monolog\Logger\WARNING.

207  {
208  $someObject = new \stdClass();
209  $someObject->property = 'anything';
210  $someObject->nest3 = new \stdClass();
211  $someObject->nest3->property = 'nothing';
212  $someObject->nest3->nest4 = 'invisible';
213 
214  $record = array(
215  'message' => 'some log message',
216  'context' => array(
217  'nest2' => $someObject,
218  ),
219  'level' => Logger::WARNING,
220  'level_name' => Logger::getLevelName(Logger::WARNING),
221  'channel' => 'test',
222  'datetime' => new \DateTime('2014-02-01 00:00:00'),
223  'extra' => array(),
224  );
225 
226  $formatter = new MongoDBFormatter(2, true);
227  $formattedResult = $formatter->format($record);
228 
229  $this->assertEquals(
230  array(
231  'nest2' => array(
232  'property' => 'anything',
233  'nest3' => '[...]',
234  'class' => 'stdClass',
235  ),
236  ),
237  $formattedResult['context']
238  );
239  }
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:52
Create styles array
The data for the language used.
static getLevelName($level)
Gets the name of the logging level.
Definition: Logger.php:458
+ Here is the call graph for this function:

◆ testRecursiveFormat()

Monolog\Formatter\MongoDBFormatterTest::testRecursiveFormat ( )

Definition at line 83 of file MongoDBFormatterTest.php.

References array, Monolog\Logger\getLevelName(), and Monolog\Logger\WARNING.

84  {
85  $someObject = new \stdClass();
86  $someObject->foo = 'something';
87  $someObject->bar = 'stuff';
88 
89  $record = array(
90  'message' => 'some log message',
91  'context' => array(
92  'stuff' => new \DateTime('2014-02-01 02:31:33'),
93  'some_object' => $someObject,
94  'context_string' => 'some string',
95  'context_int' => 123456,
96  'except' => new \Exception('exception message', 987),
97  ),
98  'level' => Logger::WARNING,
99  'level_name' => Logger::getLevelName(Logger::WARNING),
100  'channel' => 'test',
101  'datetime' => new \DateTime('2014-02-01 00:00:00'),
102  'extra' => array(),
103  );
104 
105  $formatter = new MongoDBFormatter();
106  $formattedRecord = $formatter->format($record);
107 
108  $this->assertCount(5, $formattedRecord['context']);
109  $this->assertInstanceOf('\MongoDate', $formattedRecord['context']['stuff']);
110  $this->assertEquals('0.00000000 1391221893', $formattedRecord['context']['stuff']->__toString());
111  $this->assertEquals(
112  array(
113  'foo' => 'something',
114  'bar' => 'stuff',
115  'class' => 'stdClass',
116  ),
117  $formattedRecord['context']['some_object']
118  );
119  $this->assertEquals('some string', $formattedRecord['context']['context_string']);
120  $this->assertEquals(123456, $formattedRecord['context']['context_int']);
121 
122  $this->assertCount(5, $formattedRecord['context']['except']);
123  $this->assertEquals('exception message', $formattedRecord['context']['except']['message']);
124  $this->assertEquals(987, $formattedRecord['context']['except']['code']);
125  $this->assertInternalType('string', $formattedRecord['context']['except']['file']);
126  $this->assertInternalType('integer', $formattedRecord['context']['except']['code']);
127  $this->assertInternalType('string', $formattedRecord['context']['except']['trace']);
128  $this->assertEquals('Exception', $formattedRecord['context']['except']['class']);
129  }
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:52
Create styles array
The data for the language used.
static getLevelName($level)
Gets the name of the logging level.
Definition: Logger.php:458
+ Here is the call graph for this function:

◆ testSimpleFormat()

Monolog\Formatter\MongoDBFormatterTest::testSimpleFormat ( )

Definition at line 57 of file MongoDBFormatterTest.php.

References array, Monolog\Logger\getLevelName(), and Monolog\Logger\WARNING.

58  {
59  $record = array(
60  'message' => 'some log message',
61  'context' => array(),
62  'level' => Logger::WARNING,
63  'level_name' => Logger::getLevelName(Logger::WARNING),
64  'channel' => 'test',
65  'datetime' => new \DateTime('2014-02-01 00:00:00'),
66  'extra' => array(),
67  );
68 
69  $formatter = new MongoDBFormatter();
70  $formattedRecord = $formatter->format($record);
71 
72  $this->assertCount(7, $formattedRecord);
73  $this->assertEquals('some log message', $formattedRecord['message']);
74  $this->assertEquals(array(), $formattedRecord['context']);
75  $this->assertEquals(Logger::WARNING, $formattedRecord['level']);
76  $this->assertEquals(Logger::getLevelName(Logger::WARNING), $formattedRecord['level_name']);
77  $this->assertEquals('test', $formattedRecord['channel']);
78  $this->assertInstanceOf('\MongoDate', $formattedRecord['datetime']);
79  $this->assertEquals('0.00000000 1391212800', $formattedRecord['datetime']->__toString());
80  $this->assertEquals(array(), $formattedRecord['extra']);
81  }
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:52
Create styles array
The data for the language used.
static getLevelName($level)
Gets the name of the logging level.
Definition: Logger.php:458
+ Here is the call graph for this function:

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