21 \PHPUnit_Framework_Error_Warning::$enabled =
true;
23 return parent::tearDown();
29 $formatted = $formatter->format(
array(
30 'level_name' =>
'ERROR',
33 'datetime' =>
new \DateTime,
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)',
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(),
90 if (!class_exists(
'SoapFault')) {
91 $this->markTestSkipped(
'Requires the soap extension');
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',
118 $this->setExpectedException(
'RuntimeException',
'Could not convert to string');
119 $formatter->format(
array(
127 $formatted = $formatter->formatBatch(
array(
129 'level_name' =>
'CRITICAL',
132 'context' =>
array(),
133 'datetime' =>
new \DateTime,
137 'level_name' =>
'WARNING',
140 'context' =>
array(),
141 'datetime' =>
new \DateTime,
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'),
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");
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);
199 $resource = fopen(__FILE__,
'r');
203 set_error_handler(
function ($level, $message,
$file, $line, $context) use ($that) {
204 if (error_reporting() & $level) {
205 restore_error_handler();
206 $that->fail(
"$message should not be raised");
211 $reflMethod = new \ReflectionMethod($formatter,
'toJson');
212 $reflMethod->setAccessible(
true);
213 $res = $reflMethod->invoke($formatter,
array($resource),
true);
215 restore_error_handler();
217 $this->assertEquals(@json_encode(
array($resource)),
$res);
225 if (version_compare(PHP_VERSION,
'5.5.0',
'<')) {
227 \PHPUnit_Framework_Error_Warning::$enabled =
false;
230 $reflMethod = new \ReflectionMethod($formatter,
'toJson');
231 $reflMethod->setAccessible(
true);
234 $record = new \stdClass;
235 $record->message =
"\xB1\x31";
236 $res = $reflMethod->invoke($formatter, $record);
237 if (PHP_VERSION_ID < 50500 &&
$res ===
'{"message":null}') {
238 throw new \RuntimeException(
'PHP 5.3/5.4 throw a warning and null the value instead of returning false entirely');
244 if (version_compare(PHP_VERSION,
'5.5.0',
'<')) {
246 \PHPUnit_Framework_Error_Warning::$enabled =
false;
249 $reflMethod = new \ReflectionMethod($formatter,
'toJson');
250 $reflMethod->setAccessible(
true);
252 $res = $reflMethod->invoke($formatter,
array(
'message' =>
"\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE"));
254 if (version_compare(PHP_VERSION,
'5.5.0',
'>=')) {
255 $this->assertSame(
'{"message":"€ŠšŽžŒœŸ"}',
$res);
259 $this->assertSame(
'{"message":null}',
$res);
272 $formatter->detectAndCleanUtf8(
$in);
273 $this->assertSame($expect,
$in);
278 $obj = new \stdClass;
281 'null' =>
array(null, null),
282 'int' =>
array(123, 123),
283 'float' =>
array(123.45, 123.45),
284 'bool false' =>
array(
false,
false),
285 'bool true' =>
array(
true,
true),
286 'ascii string' =>
array(
'abcdef',
'abcdef'),
287 'latin9 string' =>
array(
"\xB1\x31\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE\xFF",
'±1€ŠšŽžŒœŸÿ'),
288 'unicode string' =>
array(
'¤¦¨´¸¼½¾€ŠšŽžŒœŸ',
'¤¦¨´¸¼½¾€ŠšŽžŒœŸ'),
291 'object' =>
array($obj, $obj),
303 $reflMethod = new \ReflectionMethod($formatter,
'handleJsonError');
304 $reflMethod->setAccessible(
true);
306 $this->setExpectedException(
'RuntimeException', $msg);
307 $reflMethod->invoke($formatter,
$code,
'faked');
313 'depth' =>
array(JSON_ERROR_DEPTH,
'Maximum stack depth exceeded'),
314 'state' =>
array(JSON_ERROR_STATE_MISMATCH,
'Underflow or the modes mismatch'),
315 'ctrl' =>
array(JSON_ERROR_CTRL_CHAR,
'Unexpected control character found'),
316 'default' =>
array(-1,
'Unknown error'),
323 $this->markTestSkipped(
'Not supported in HHVM since it detects errors differently');
328 set_error_handler(
function ($errno, $errstr, $errfile, $errline) {
329 throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
334 $resource = fopen(
'php://memory',
'rw+');
335 fwrite($resource,
'test_resource');
337 $wrappedResource->foo = $resource;
339 array_keys($wrappedResource);
341 restore_error_handler();
345 $record =
array(
'context' =>
array(
'exception' => $e));
346 $result = $formatter->format($record);
349 '%"resource":"\[resource\] \(stream\)"%',
350 $result[
'context'][
'exception'][
'trace'][0]
353 if (version_compare(PHP_VERSION,
'5.5.0',
'>=')) {
354 $pattern =
'%"wrappedResource":"\[object\] \(Monolog\\\\\\\\Formatter\\\\\\\\TestFooNorm: \)"%';
356 $pattern =
'%\\\\"foo\\\\":null%';
362 $result[
'context'][
'exception'][
'trace'][0]
387 $this->resource = $resource;
393 fseek($this->resource, 0);
395 return $this->foo .
' - ' . (
string) stream_get_contents($this->resource);
403 throw new \RuntimeException(
'Could not convert to string');
Add rich text string
The name of the decorator.
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Create styles array
The data for the language used.
if(php_sapi_name() !='cli') $in
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'