Monolog
More...
◆ providesDetectAndCleanUtf8()
Monolog\Formatter\NormalizerFormatterTest::providesDetectAndCleanUtf8 |
( |
| ) |
|
Definition at line 321 of file NormalizerFormatterTest.php.
323 $obj = new \stdClass;
326 'null' => array(null, null),
327 'int' => array(123, 123),
328 'float' => array(123.45, 123.45),
329 'bool false' => array(
false,
false),
330 'bool true' => array(
true,
true),
331 'ascii string' => array(
'abcdef',
'abcdef'),
332 'latin9 string' => array(
"\xB1\x31\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE\xFF",
'±1€ŠšŽžŒœŸÿ'),
333 'unicode string' => array(
'¤¦¨´¸¼½¾€ŠšŽžŒœŸ',
'¤¦¨´¸¼½¾€ŠšŽžŒœŸ'),
334 'empty array' => array(array(), array()),
335 'array' => array(array(
'abcdef'), array(
'abcdef')),
336 'object' => array($obj, $obj),
◆ providesHandleJsonErrorFailure()
Monolog\Formatter\NormalizerFormatterTest::providesHandleJsonErrorFailure |
( |
| ) |
|
Definition at line 355 of file NormalizerFormatterTest.php.
358 'depth' => array(JSON_ERROR_DEPTH,
'Maximum stack depth exceeded'),
359 'state' => array(JSON_ERROR_STATE_MISMATCH,
'Underflow or the modes mismatch'),
360 'ctrl' => array(JSON_ERROR_CTRL_CHAR,
'Unexpected control character found'),
361 'default' => array(-1,
'Unknown error'),
◆ tearDown()
Monolog\Formatter\NormalizerFormatterTest::tearDown |
( |
| ) |
|
◆ testBatchFormat()
Monolog\Formatter\NormalizerFormatterTest::testBatchFormat |
( |
| ) |
|
Definition at line 124 of file NormalizerFormatterTest.php.
126 $formatter =
new NormalizerFormatter(
'Y-m-d');
127 $formatted = $formatter->formatBatch(array(
129 'level_name' =>
'CRITICAL',
132 'context' => array(),
137 'level_name' =>
'WARNING',
140 'context' => array(),
145 $this->assertEquals(array(
147 'level_name' =>
'CRITICAL',
150 'context' => array(),
151 'datetime' => date(
'Y-m-d'),
155 'level_name' =>
'WARNING',
158 'context' => array(),
159 'datetime' => date(
'Y-m-d'),
◆ testCanNormalizeReferences()
Monolog\Formatter\NormalizerFormatterTest::testCanNormalizeReferences |
( |
| ) |
|
Definition at line 196 of file NormalizerFormatterTest.php.
References $x, and $y.
198 $formatter =
new NormalizerFormatter();
199 $x = array(
'foo' =>
'bar');
200 $y = array(
'x' => &
$x);
202 $formatter->format(
$y);
◆ testConvertsInvalidEncodingAsLatin9()
Monolog\Formatter\NormalizerFormatterTest::testConvertsInvalidEncodingAsLatin9 |
( |
| ) |
|
Definition at line 287 of file NormalizerFormatterTest.php.
References $res.
289 if (version_compare(PHP_VERSION,
'5.5.0',
'<')) {
291 \PHPUnit_Framework_Error_Warning::$enabled =
false;
293 $formatter =
new NormalizerFormatter();
294 $reflMethod = new \ReflectionMethod($formatter,
'toJson');
295 $reflMethod->setAccessible(
true);
297 $res = $reflMethod->invoke($formatter, array(
'message' =>
"\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE"));
299 if (version_compare(PHP_VERSION,
'5.5.0',
'>=')) {
300 $this->assertSame(
'{"message":"€ŠšŽžŒœŸ"}',
$res);
304 $this->assertSame(
'{"message":null}',
$res);
foreach($_POST as $key=> $value) $res
◆ testDetectAndCleanUtf8()
Monolog\Formatter\NormalizerFormatterTest::testDetectAndCleanUtf8 |
( |
|
$in, |
|
|
|
$expect |
|
) |
| |
- Parameters
-
mixed | $in | Input |
mixed | $expect | Expected output Monolog::detectAndCleanUtf8 providesDetectAndCleanUtf8 |
Definition at line 314 of file NormalizerFormatterTest.php.
References $in.
316 $formatter =
new NormalizerFormatter();
317 $formatter->detectAndCleanUtf8(
$in);
318 $this->assertSame($expect,
$in);
if(php_sapi_name() !='cli') $in
◆ testExceptionTraceDoesNotLeakCallUserFuncArgs()
Monolog\Formatter\NormalizerFormatterTest::testExceptionTraceDoesNotLeakCallUserFuncArgs |
( |
| ) |
|
Definition at line 411 of file NormalizerFormatterTest.php.
References $result.
414 $arg =
new TestInfoLeak;
415 call_user_func(array($this,
'throwHelper'), $arg, $dt =
new \
DateTime());
419 $formatter =
new NormalizerFormatter();
420 $record = array(
'context' => array(
'exception' => $e));
421 $result = $formatter->format($record);
424 '{"function":"throwHelper","class":"Monolog\\\\Formatter\\\\NormalizerFormatterTest","type":"->","args":["[object] (Monolog\\\\Formatter\\\\TestInfoLeak)","'.$dt->format(
'Y-m-d H:i:s').
'"]}',
425 $result[
'context'][
'exception'][
'trace'][0]
◆ testExceptionTraceWithArgs()
Monolog\Formatter\NormalizerFormatterTest::testExceptionTraceWithArgs |
( |
| ) |
|
Definition at line 365 of file NormalizerFormatterTest.php.
References $result.
367 if (defined(
'HHVM_VERSION')) {
368 $this->markTestSkipped(
'Not supported in HHVM since it detects errors differently');
373 set_error_handler(
function ($errno, $errstr, $errfile, $errline) {
374 throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
379 $resource =
fopen(
'php://memory',
'rw+');
380 fwrite($resource,
'test_resource');
381 $wrappedResource =
new TestFooNorm;
382 $wrappedResource->foo = $resource;
384 array_keys($wrappedResource);
386 restore_error_handler();
389 $formatter =
new NormalizerFormatter();
390 $record = array(
'context' => array(
'exception' => $e));
391 $result = $formatter->format($record);
394 '%"resource":"\[resource\] \(stream\)"%',
395 $result[
'context'][
'exception'][
'trace'][0]
398 if (version_compare(PHP_VERSION,
'5.5.0',
'>=')) {
399 $pattern =
'%"wrappedResource":"\[object\] \(Monolog\\\\\\\\Formatter\\\\\\\\TestFooNorm: \)"%';
401 $pattern =
'%\\\\"foo\\\\":null%';
407 $result[
'context'][
'exception'][
'trace'][0]
◆ testFormat()
Monolog\Formatter\NormalizerFormatterTest::testFormat |
( |
| ) |
|
Definition at line 26 of file NormalizerFormatterTest.php.
28 $formatter =
new NormalizerFormatter(
'Y-m-d');
29 $formatted = $formatter->format(array(
30 'level_name' =>
'ERROR',
34 'extra' => array(
'foo' =>
new TestFooNorm,
'bar' =>
new TestBarNorm,
'baz' => array(),
'res' =>
fopen(
'php://memory',
'rb')),
44 $this->assertEquals(array(
45 'level_name' =>
'ERROR',
48 'datetime' => date(
'Y-m-d'),
50 'foo' =>
'[object] (Monolog\\Formatter\\TestFooNorm: {"foo":"foo"})',
51 'bar' =>
'[object] (Monolog\\Formatter\\TestBarNorm: bar)',
53 'res' =>
'[resource] (stream)',
◆ testFormatExceptions()
Monolog\Formatter\NormalizerFormatterTest::testFormatExceptions |
( |
| ) |
|
Definition at line 65 of file NormalizerFormatterTest.php.
67 $formatter =
new NormalizerFormatter(
'Y-m-d');
68 $e = new \LogicException(
'bar');
69 $e2 = new \RuntimeException(
'foo', 0, $e);
70 $formatted = $formatter->format(array(
74 $this->assertGreaterThan(5, count($formatted[
'exception'][
'trace']));
75 $this->assertTrue(isset($formatted[
'exception'][
'previous']));
76 unset($formatted[
'exception'][
'trace'], $formatted[
'exception'][
'previous']);
78 $this->assertEquals(array(
80 'class' => get_class($e2),
81 'message' => $e2->getMessage(),
82 'code' => $e2->getCode(),
83 'file' => $e2->getFile().
':'.$e2->getLine(),
◆ testFormatSoapFaultException()
Monolog\Formatter\NormalizerFormatterTest::testFormatSoapFaultException |
( |
| ) |
|
Definition at line 88 of file NormalizerFormatterTest.php.
90 if (!class_exists(
'SoapFault')) {
91 $this->markTestSkipped(
'Requires the soap extension');
94 $formatter =
new NormalizerFormatter(
'Y-m-d');
95 $e = new \SoapFault(
'foo',
'bar',
'hello',
'world');
96 $formatted = $formatter->format(array(
100 unset($formatted[
'exception'][
'trace']);
102 $this->assertEquals(array(
103 'exception' => array(
104 'class' =>
'SoapFault',
107 'file' => $e->getFile().
':'.$e->getLine(),
108 'faultcode' =>
'foo',
109 'faultactor' =>
'hello',
◆ testFormatToStringExceptionHandle()
Monolog\Formatter\NormalizerFormatterTest::testFormatToStringExceptionHandle |
( |
| ) |
|
Definition at line 115 of file NormalizerFormatterTest.php.
117 $formatter =
new NormalizerFormatter(
'Y-m-d');
118 $this->setExpectedException(
'RuntimeException',
'Could not convert to string');
119 $formatter->format(array(
120 'myObject' =>
new TestToStringError(),
◆ testHandleJsonErrorFailure()
Monolog\Formatter\NormalizerFormatterTest::testHandleJsonErrorFailure |
( |
|
$code, |
|
|
|
$msg |
|
) |
| |
- Parameters
-
int | $code | |
string | $msg | providesHandleJsonErrorFailure |
Definition at line 345 of file NormalizerFormatterTest.php.
References $code.
347 $formatter =
new NormalizerFormatter();
348 $reflMethod = new \ReflectionMethod($formatter,
'handleJsonError');
349 $reflMethod->setAccessible(
true);
351 $this->setExpectedException(
'RuntimeException', $msg);
352 $reflMethod->invoke($formatter,
$code,
'faked');
◆ testIgnoresInvalidTypes()
Monolog\Formatter\NormalizerFormatterTest::testIgnoresInvalidTypes |
( |
| ) |
|
Definition at line 205 of file NormalizerFormatterTest.php.
References $context, $message, and $res.
208 $resource =
fopen(__FILE__,
'r');
212 set_error_handler(
function ($level,
$message, $file, $line,
$context) use ($that) {
213 if (error_reporting() & $level) {
214 restore_error_handler();
215 $that->fail(
"$message should not be raised");
219 $formatter =
new NormalizerFormatter();
220 $reflMethod = new \ReflectionMethod($formatter,
'toJson');
221 $reflMethod->setAccessible(
true);
222 $res = $reflMethod->invoke($formatter, array($resource),
true);
224 restore_error_handler();
226 $this->assertEquals(@json_encode(array($resource)),
$res);
catch(Exception $e) $message
foreach($_POST as $key=> $value) $res
◆ testIgnoresRecursiveObjectReferences()
Monolog\Formatter\NormalizerFormatterTest::testIgnoresRecursiveObjectReferences |
( |
| ) |
|
Test issue #137.
Definition at line 168 of file NormalizerFormatterTest.php.
References $context, $message, and $res.
171 $foo = new \stdClass();
172 $bar = new \stdClass();
179 set_error_handler(
function ($level,
$message, $file, $line,
$context) use ($that) {
180 if (error_reporting() & $level) {
181 restore_error_handler();
182 $that->fail(
"$message should not be raised");
186 $formatter =
new NormalizerFormatter();
187 $reflMethod = new \ReflectionMethod($formatter,
'toJson');
188 $reflMethod->setAccessible(
true);
189 $res = $reflMethod->invoke($formatter, array($foo, $bar),
true);
191 restore_error_handler();
193 $this->assertEquals(@json_encode(array($foo, $bar)),
$res);
catch(Exception $e) $message
foreach($_POST as $key=> $value) $res
◆ testNormalizeHandleLargeArrays()
Monolog\Formatter\NormalizerFormatterTest::testNormalizeHandleLargeArrays |
( |
| ) |
|
Definition at line 247 of file NormalizerFormatterTest.php.
References $res.
249 $formatter =
new NormalizerFormatter();
250 $largeArray = range(1, 2000);
252 $res = $formatter->format(array(
253 'level_name' =>
'CRITICAL',
256 'context' => array($largeArray),
261 $this->assertCount(1001,
$res[
'context'][0]);
262 $this->assertEquals(
'Over 1000 items (2000 total), aborting normalization',
$res[
'context'][0][
'...']);
foreach($_POST as $key=> $value) $res
◆ testNormalizeHandleLargeArraysWithExactly1000Items()
Monolog\Formatter\NormalizerFormatterTest::testNormalizeHandleLargeArraysWithExactly1000Items |
( |
| ) |
|
Definition at line 229 of file NormalizerFormatterTest.php.
References $res.
231 $formatter =
new NormalizerFormatter();
232 $largeArray = range(1, 1000);
234 $res = $formatter->format(array(
235 'level_name' =>
'CRITICAL',
238 'context' => array($largeArray),
243 $this->assertCount(1000,
$res[
'context'][0]);
244 $this->assertArrayNotHasKey(
'...',
$res[
'context'][0]);
foreach($_POST as $key=> $value) $res
◆ testThrowsOnInvalidEncoding()
Monolog\Formatter\NormalizerFormatterTest::testThrowsOnInvalidEncoding |
( |
| ) |
|
RuntimeException
Definition at line 268 of file NormalizerFormatterTest.php.
References $res.
270 if (version_compare(PHP_VERSION,
'5.5.0',
'<')) {
272 \PHPUnit_Framework_Error_Warning::$enabled =
false;
274 $formatter =
new NormalizerFormatter();
275 $reflMethod = new \ReflectionMethod($formatter,
'toJson');
276 $reflMethod->setAccessible(
true);
279 $record = new \stdClass;
280 $record->message =
"\xB1\x31";
281 $res = $reflMethod->invoke($formatter, $record);
282 if (PHP_VERSION_ID < 50500 &&
$res ===
'{"message":null}') {
283 throw new \RuntimeException(
'PHP 5.3/5.4 throw a warning and null the value instead of returning false entirely');
foreach($_POST as $key=> $value) $res
◆ throwHelper()
Monolog\Formatter\NormalizerFormatterTest::throwHelper |
( |
|
$arg | ) |
|
|
private |
The documentation for this class was generated from the following file: