Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
--TEST--
2
Log: _extractMessage() [Zend Engine 2.2]
3
--SKIPIF--
4
<?php if (version_compare(zend_version(), "2.2.0", "<")) die('skip'); ?>
5
--INI--
6
date.timezone=UTC
7
--FILE--
8
<?php
9
 
10
require_once 'Log.php';
11
 
12
$conf = array('lineFormat' => '%2$s [%3$s] %4$s');
13
$logger = Log::singleton('console', '', 'ident', $conf);
14
 
15
/* Logging a regular string. */
16
$logger->log('String');
17
 
18
/* Logging a bare object. */
19
class BareObject {}
20
$logger->log(new BareObject());
21
 
22
/* Logging an object with a getMessage() method. */
23
class GetMessageObject { function getMessage() { return "getMessage"; } }
24
$logger->log(new GetMessageObject());
25
 
26
/* Logging an object with a toString() method. */
27
class ToStringObject { function toString() { return "toString"; } }
28
$logger->log(new ToStringObject());
29
 
30
/* Logging an object with a __toString() method using casting. */
31
class CastableObject { function __toString() { return "__toString"; } }
32
$logger->log(new CastableObject());
33
 
34
/* Logging a PEAR_Error object. */
35
require_once 'PEAR.php';
36
$logger->log(new PEAR_Error('PEAR_Error object', 100));
37
 
38
/* Logging an array. */
39
$logger->log(array(1, 2, 'three' => 3));
40
 
41
/* Logging an array with scalar 'message' keys. */
42
$logger->log(array('message' => 'Message Key'));
43
$logger->log(array('message' => 50));
44
 
45
/* Logging an array with a non-scalar 'message' key. */
46
$logger->log(array('message' => array(1, 2, 3)));
47
 
48
--EXPECT--
49
ident [info] String
50
ident [info] BareObject::__set_state(array(
51
))
52
ident [info] getMessage
53
ident [info] toString
54
ident [info] __toString
55
ident [info] PEAR_Error object
56
ident [info] array (
57
 
58
  1 => 2,
59
  'three' => 3,
60
)
61
ident [info] Message Key
62
ident [info] 50
63
ident [info] array (
64
 
65
  1 => 2,
66
  2 => 3,
67
)